Reputation: 1557
I'm currently trying to set up a site that is rendered on the server side with Mustache.java: https://github.com/spullara/mustache.java
However, for some pages, I need to also render on the client side with Mustache.js. However, Mustache.java processes any tags in the Mustache I want to process only on the client side. How can I make mustache ignore certain tags?
Template:
<div>{{process_on_backend}}</div>
<script id="mustache-to-be-rendered-in-browser" type="x-tmpl-mustache">
<div>
{{process_on_frontend}}
</div>
</script>
What I want it to compile to:
<div>This should be processed.</div>
<script id="mustache-to-be-rendered-in-browser" type="x-tmpl-mustache">
<div>
{{process_on_frontend}}
</div>
</script>
What it actually compiles to:
<div>This should be processed</div>
<script id="mustache-to-be-rendered-in-browser" type="x-tmpl-mustache">
<div>
This should not be processed.
</div>
</script>
I saw in another question that using {{={{{ }}}=}}
to temporarily change the delimiters might work, but when I tried it, I got a 500 error: com.github.mustachejava.MustacheException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
and I'm pretty sure that it isn't supported in mustache.java.
Upvotes: 1
Views: 902
Reputation: 1557
I figured it out. For some reason using '{' in the new delimiter seems to throw it off. Instead, I used {{=<% %>=}}
and it works fine.
Upvotes: 2