This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
anubite
Hi
I am trying to render partial's content into JS variable. But I ran into a problem - disappearing closing tags.
Partial code looks like this:
<h1>Test</h1><p>Lorem ipsum dolor sit amet.</p>
In the page I have this:
{% partial 'test' %}
<script type="text/javascript">
var html = "{% partial 'test' %}";
</script>
And the output is:
<h1>Test</h1><p>Lorem ipsum dolor sit amet.</p>
<script type="text/javascript">
var html = "<h1>Test<p>Lorem ipsum dolor sit amet.";
</script>
As you can see closing tags disappeared. Am I using it wrong or is this a bug?
Thanks for your help!
Davox
I had the same problem and solved it as follows:
{% set testHtml = "<h1>Test</h1><p>Lorem ipsum dolor sit amet.</p>" %}
<script type="text/javascript">
var html = "{{ testHtml|e('js') }}";
</script>
1-2 of 2