Href stripped in liquid

Am trying to add an else statement to my custom module but when I do it doesn’t show the Document URL as a hyperlink, just plain text -

{% if Link == N/A %}Document URL: {{this[‘Link’]}}

{% else %}
Document URL: < a href="{{this[‘Link’]}}">{{this[‘Link’]}}< /a >{%endif%}

Any ideas what might cause the href to be stripped?

Hi,
Did you try it in an “< a >” tag?
e.g., Document URL:
< a href="{{this[‘Link’]}}">
{{this[‘Link’]}}
< /a >

Yes sorry LaJoie I did, the forum post just stripped it out.

Oh, ok, can you check if the following works?
I tested it, it should be fine.
(P.S.: you were missing this.Link at the beginning)

{% if this.Link == N/A %}
Document URL: <a href="/">Specify a new link here because the field is empty</a>
{% else %}
Document URL: <a href="{{this.Link}}">{{this.Link}}</a>
{%endif%}

While there looks to be some issues with the IF statement the problem with the <a> element could be to do with regular quotes vs ‘smart’ quotes.
Going by your code sample you have smart quotes in your liquid tag which won’t work as they are seen as a different character.
Note the difference in the following:
image
The bottom one uses smart quotes around the Url property and it doesn’t render the data.

It’s hard to tell if that is actually the issue with your implementation as it could have happened from pasting here in the Forum… but that would be my guess.

PS: you can use ` and ``` to surround text here in the forum to correctly format it as code, or use the style toolbar at the top to format code. It makes it a lot easier to help troubleshoot :slight_smile: