0

I use handlebars like this somewhere inside the body of the HTML

{{template.header}}

Everything works as expected till I want to add css styles/or HTML tags as the "header" content (styling is not as part of the parent item, because I dynamically get the styling from outside) . Eg: "header" -> <p style="font-size:14px"> My header </p>

If I try to use that I get them in the outputted result, probably as expected because I don't specify somehow that the template owner wants control over the styling inside the passed template data

Is there a way for the user to specify styling from outside and handlebars just to output the passed input styling ?

1 Answer 1

1

You can use triple brackets to render html. Just be careful because this opens you up to XSS attacks if its user input viewable by other users.

{{{template.header}}}

https://handlebarsjs.com/guide/expressions.html#html-escaping

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.