Javascript / Java的HTML模板/数据绑定库 [英] Javascript/Java HTML template/data-binding library

查看:413
本文介绍了Javascript / Java的HTML模板/数据绑定库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 客户端的Javascript实现,

  • 服务器端的Java实现

  • 轻量级语法:没有通用的代码,只有简单的表达式,

  • 但简单的for-loops,'include'和'if'。



(简而言之,语法类似于Django模板,如果它告诉你任何事情。)



有人知道满足这些要求的开源库吗?

解决方案

您是否考虑过使用胡子?它提供了非常简单的模板,可用于 java javascript



如果查看文档,可以看到简单的示例

  {{#names}} 
嗨{{name}}!
{{/ names}}

和条件:

  {{#value}} 
价值为真
{{/ value}}
{{^ value}}
价值为假
{{/ value}}

包含可由以下方式处理:使用partials,它可以让你拉另一个模板。


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?

解决方案

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.

这篇关于Javascript / Java的HTML模板/数据绑定库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆