سؤال

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