Javascript/Java HTML template/data-binding library

2019-09-20 23:46发布

I'd like to find out about libraries with the following properties:

  • Javascript implementation for client-side,
  • Java implementation for server-side,
  • light-weight syntax: no generic 'code', only simple expressions,
  • but simple for-loops, 'include', and 'if'.

(In short, the syntax would be similar to Django templates, if that tells you anything.)

Does anybody know an open-source library that fulfills these requirements?

1条回答
家丑人穷心不美
2楼-- · 2019-09-21 00:11

Have you considered using Mustache? It offers very simple templates and can be used in both java and javascript.

If you look at the docs you can see simple examples of loops:

{{#names}}
  Hi {{name}}!
{{/names}}

and conditions:

{{#value}}
  Value was true
{{/value}}
{{^value}}
  Value was false
{{/value}}

Includes can be handled by using partials, which let you pull in another template.

查看更多
登录 后发表回答