I want render variable content like html.
var export = '';
{{ export }}
but when i call this rendered as string, not html
have you tried using the safe filter to make nunjucks not auto escape the string?
{{ export | safe }}
I'm entirely sure what the problem is. Can you give a better example?
@mkoryak yes...
parser cut html code in my comment export contains input attrbiute
@jlongster
var export = '<input type="checkbox" name="export[]" value="110"';
{{export}}
Need:
render variable export in html, not plain text.
Vyacheslav: It sounds like you want the set command.
{% set export = '
On Mar 5, 2014 5:01 PM, "Vyacheslav Tsurka" notifications@github.com
wrote:
@jlongster https://github.com/jlongster
var export = ' {{export}}
Need:
render variable export in html, not plain text.
Reply to this email directly or view it on GitHubhttps://github.com/jlongster/nunjucks/issues/204#issuecomment-36814179
.
Can you show the template that you are rendering, along with the JS that you are using to render? The problem is still ambiguous.
Closing as no response from op. Create a new issue if you still need more clarification/help.
@jlongster @garygreen I think I have a similar issue. I have a Nunjucks template strings.html and am importing it into page1.html (and other places, eg page2.html) (just some sample names). Autoescape is false (default) and want to keep it that way.
strings.html has:
'{% set st1 = 'go find it yourself' %}'
page1.html has
{% from "strings.html" import st1 %}
If you can't find it here, {{ st1 }}
What I expect to see is:
If you can't find it here, go find it yourself
What I actually see is:
If you can't find it here, go find it yourself
If I change page1.html to
If you can't find it here, {{ st1|safe }}
I see:
If you can't find it here, go find it yourself
BUT, I would like to mark it safe in strings.html not in each place where I'm importing it. Doign this doesn't work (nor would I expect it to, but is there some way to mark a string as safe when setting?):
{% set st1 = '<a href="http://www.google.com">go find it yourself</a>'|safe %}
Most helpful comment
have you tried using the safe filter to make nunjucks not auto escape the string?
{{ export | safe }}