ajo variables | Community
Skip to main content
Level 4
October 22, 2024
Question

ajo variables

  • October 22, 2024
  • 1 reply
  • 1696 views

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?

1 reply

DavidKangni
Community Advisor
Community Advisor
October 22, 2024

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

David Kangni
Sukrity_Wadhwa
Community Manager
Community Manager
October 29, 2024

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!

Sukrity Wadhwa
October 8, 2025

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.

 

 


Please let us know if there is a solution for this.