fhd / clostache

{{ mustache }} for Clojure
GNU Lesser General Public License v3.0
318 stars 62 forks source link

set delimeters inside squiggly braces not handled properly #41

Open ewollesen opened 9 years ago

ewollesen commented 9 years ago

I'm trying to use clostache to insert values into a latex template. I've changed the set delimeters to <% %> because {{ occurs in latex. However, I ran into a case where I have a template like the following:

\name{<% name %>}

The resulting template (when name is "Foo") is:

\nameFoo

I looked at the code, and this seems to be a result of process-set-delimiters replacing instances of the chosen delimiters with {{ and }}, so in my example, after process-set-delimiters, template becomes:

\name{{{ name }}}

And because mustache uses {{{ as a delimiter for unescaped insertion, this is a problem. I've tested this using mustache from the command-line, and there it works as expected.

Here's a failing test case:

(deftest test-set-delimiters-with-curly-braces
  (is (= (render "{{=<% %>=}}\n{<% foo %>}" {:foo "bar"}) "{bar}")))

I looked at the code, but sadly, I'm very new to clojure and so I'm a little lost as to how to proceed to resolve this situation. If you could give me any pointers as to how this might be solved, I'll be glad to make an attempt at it.

Thanks!