trentm / molybdenum

A git repo browser (for when your git repos aren't on GitHub)
http://trentm.com/molybdenum
Other
12 stars 6 forks source link

file content with mustache template syntax isn't escaped #12

Closed trentm closed 11 years ago

trentm commented 11 years ago

e.g. https://mo.joyent.com/usb-headnode/blob/master/config/sapi/manifests/services/amon/amon/template

trentm commented 11 years ago

One should be able to do it like this:

var p = console.log;
var Mustache = require('mustache');

template = "hi {{name}}, code is\n"
    + "{{=<% %>=}}"
    + "--\n"
    + "{foo}  {{bar}}  {{{blah}}} <% bling %>\n"
    + "--\n"
    + "Hello again <% name %>.\n"
    //+ "{{={{ }}=}}"
    + "<%={{ }}=%>"
    + "bye {{name}} . Later.\n";
var view = {
    name: "Bob"
}

p(Mustache.to_html(template, view))

But for me that results in:

$ node foo.js
hi Bob, code is
--
{foo}  {{bar}}  {{{blah}}}
--
Hello again Bob.
bye {{name}} . Later.

IOW, returning back to the '{{name}}' delimiters is broken in this Mustache impl. Crap.

Basically I don't have a good answer for this right now. I just want to change to another templating lang. Perhaps hogan. Preferably https://github.com/paularmstrong/swig if that is sufficient.

pijewski commented 11 years ago

Thanks a ton!