0

I have the following template:

<!DOCTYPE HTML>
<html>
<head>
<link href="css/style.css" rel="stylesheet"/>
<script type="text/javascript" src="/js/libs-0001.js" async="async"></script>
<script type="text/javascript" src="/js/app-0004.js" async="async"></script>
<script>
var name = {literal}<%= name %>{/literal};
var version = {literal}<%= version %>{/literal}};
</script>
</head><body></body></html>

Like in smarty, from php, I want to use {literal} declarations in the template, under the script session.

How to do this in locomotivejs views?

ayr-ton
  • 353
  • 1
  • 4
  • 13

1 Answers1

0

As far as I understand {literal}/{/literal}, everything between those tags isn't interpreted. EJS templates don't have something similar, although there are ways of circumventing that.

One way is to configure EJS to use different open/close tags, described here.

Another way is to use a different templating engine altogether, which isn't too difficult since LocomotiveJS isn't hardcoded to using EJS templates. I like the Swig templating engine myself, which has the {% raw %} tag that seems to do the same as {literal}.

Community
  • 1
  • 1
robertklep
  • 198,204
  • 35
  • 394
  • 381