I would like to use mustache templates in both Java and JavaScript. I have actually used Mustache.js extensively and love it. But I have not used Mustache.java yet.

Are there any known conflicts or incompatibilities between them? Meaning -- how realistic is it to expect I could use the same templates in both languages without problems? Or at least, can folks write templates without having to worry about special things needing to be done depending on the language used?

有帮助吗?

解决方案

They both conform to the mustache specifications, passing related tests.

Therefore there shouldn't be any noticeable differences between them (excluding performance).

其他提示

Here is an example -

In Mustache.js -

{{#persons.length}}
<h2>Persons:</h2>
<ul>
  {{#persons}}
    <li>{{name}}</li>
  {{/persons}}
</ul>
{{/persons.length}}

In Mustache.java -

{{^persons.isEmpty}}
<h2>Persons:</h2>
<ul>
  {{#persons}}
    <li>{{name}}</li>
  {{/persons}}
</ul>
{{/persons.isEmpty}}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top