How can I pass an HTML tag as a variable in AJO?
I want to declare a variable that contains a hyperlink. For example:
{% let abc = "<p>hi this is my url <a href=\"https://www.google.com\">Google</a></p>" %}
However, when I display this variable in my Handlebars template, I'm getting an unexpected output, such as:
"Hi this is my url <p>hi this is my url <a href="https://www.google.com">Google</a></p>"
Questions:
How can I correctly handle HTML tags in a variable?
How can I properly include quotes (") in the variable declaration?
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Ajo_WisdomChase
AJO is using Handlebars as interpreted. To correctly handle HTML tags in a variable using Handlebars, you need to use triple curly braces ({{{ variable}}}). This tells Handlebars not to escape the HTML characters, allowing the HTML code to be rendered as part of the final output.
You're doing the escaping correctly when definig your variable abc.
Please try {{{abc}}}
Thanks,
David
Views
Replies
Total Likes
Hi @Ajo_WisdomChase,
Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.
Thanks!
Views
Replies
Total Likes
Hi @DavidKangni @Sukrity_Wadhwa
I'm encountering an error while using triple curly braces {{{variable}}}. Could you please help me? Ajo also added " " quotes at the beginning and end.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies