Javascript/Java HTML template/data-binding library [closed]

穿精又带淫゛_ 提交于 2019-12-13 23:39:37

问题


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:


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.



来源:https://stackoverflow.com/questions/13349082/javascript-java-html-template-data-binding-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!