How can I disable the special mode of Latte in <script> tag?

Notice: This thread is very old.
MartyIX
Member | 217
+
0
-

Hi,

Latte handles differently the two following cases:

1)

<script>
{$variable} {* additional quotes are added to the output *}
</script>

2)

{$variable} {* that is not wrapped in a <script> tag *}

I would like to know if I can disable Latte's behavior in the first scenario and make it work as in the second scenario. Why should I need it? Well, have a look at Handlebars.js template for example:

<script id="entry-template" type="text/x-handlebars-template">
  template content {* This is not JavaScript and <script n:syntax="off"> is not a solution either. *}
</script>

(My true reason is rather more obscure but let's not dwell on it. :))

Thanks

petr.pavel
Member | 532
+
0
-

You could capture “template content” outside <script></script> and then insert it in there with |noescape. Would that help?

MartyIX
Member | 217
+
0
-

Yes, I know but I would prefer a “clean” solution.

matopeto
Member | 395
+
0
-

what about:

{!$variable}

Or with custom escaping:

{!htmlspecialchars($variable)}

Last edited by matopeto (2014-02-21 12:51)

Majkl578
Moderator | 1364
+
0
-

Last time I needed this, I used something like {!$foo|escapeJs}.

David Grudl
Nette Core | 7781
+
0
-

What about <script>{contentType html}