In my theme, I have to output a toggle link like this:
<a class="hl__link-tag hl__link-tag--with-arrow js-show-more-text-link" href="#" title="Click to show more / less text" aria-expanded="false" aria-controls="showMoreText{{ paragraph.id() }}"><span class="hl__link-tag__toggle-text">Show Less</span><span>Show More</span></a>
Its not a real field or anything like that. Is there a way I can use link
or path
functions to generate this output instead? I am guessing since the title has two spans in it that I cannot, but lets assume there were no spans, I'd like to know if this is possible.
I tried:
{{ link('Show More', 'internal:#') }}
and
{{ link('Show More', '#') }}
The first one creates an empty href, which does not work. The second throws a fatal error.
a
element better usehref="javascript:void(0)"
. Related discussion: stackoverflow.com/q/134845/2199525<button>{{ 'Show more'|t }}</button>
.