doT icon indicating copy to clipboard operation
doT copied to clipboard

Support for literals is missing?

Open nerdo opened this issue 13 years ago • 1 comments

It seems like there's no way to add literal text that would otherwise get interpreted as template tags.

For example, I'm using node.js + Backbone and would like to use doT as the template engine for the client and server side, so I've got a template that has something like this in it for the client:

<script type="text/x-dot-template" id="choice-template">
    <ul>
        {{~ it.question.choices :choice}}
        <li>{{=choice.get("label")}}</li>
        {{~}}
    </ul>
</script>

I don't want those script tags to be interpreted by doT on the server-side, because they're meant for the client-side to consume, but there doesn't seem to be a way to tell doT not to process parts of a template.

nerdo avatar Feb 10 '13 03:02 nerdo

One of the solution is to use <%%> for server side interpolation and {{}} for client side.

All you need to do is to change doT settings

I did it in koa-dot, for example, with a bit friendlier api.

epoberezkin avatar Nov 21 '15 19:11 epoberezkin