1

I read on the handlebars js website that...

Alternative delimeters are not supported.

... and unfortunately it conflicts with Angular JS. I want to do something like what I can do in handlebars...

.json

{
  "people": [{"name":"joe"}, {"name":"jay"}, {"name":"jim"}]
}

.tpl.html

{{={% %}=}}

{%#people%}
   <li>{%name%}: {{localtime('{%name%}')}}</li>
{%/people%}

And end up with...

<li>joe: {{localtime('joe')}}</li>
<li>jay: {{localtime('jay')}}</li>
<li>jim: {{localtime('jim')}}</li>

... which is ready for angular js to process.

I do not want to alter angular js delimiters, I use them much more heavily throughout the app. The best I can come up with, is to parse the HTML, and replace angular delimiters with a unique token, then swap instances of {% and %} with {{ and }}, process with handlebars, and then replace the tokens with original angular delimiters again on the processed output.

This seems like far too much work. Is there another alternative?

I am using grunt, is there a plugin to do what I am trying to do here?

Billy Moon
  • 57,113
  • 24
  • 136
  • 237

0 Answers0