Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unscape HTML variables #3

Open
imayatech opened this issue Jul 2, 2023 · 1 comment
Open

Unscape HTML variables #3

imayatech opened this issue Jul 2, 2023 · 1 comment

Comments

@imayatech
Copy link

Is a way to pass HTML content in a variable and disable the escaping process?

P.e.:

<html><body>
{%$myvar = "<b>Hello</b> world"%}
{%$myvar}
</body></html>

Expected output:

<html><body>
<b>Hello</b> world
</body></html>
@fefit
Copy link
Owner

fefit commented Jul 4, 2023

@imayatech since FET will translate the code into html/template template code, the func.go provides a method named safe to allowed HTML output.

func safe(html string) template.HTML {

so you can use the method in the code like below:

<html><body>
{%$myvar = "<b>Hello</b> world"|safe%}
{%$myvar}
</body></html>

I hope that can solves your problem. thx for your issue~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants