客户端和服务器端渲染的模板语言 [英] Templating language for both client-side and server-side rendering

查看:106
本文介绍了客户端和服务器端渲染的模板语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究JavaScript模板,以呈现我们的视图。目标是能够为启用JavaScript的用户呈现客户端,从而为那些没有的用户(和搜寻器)呈现相同的模板/数据服务器端。

I'm investigating JavaScript templates as a way to render our views. The goal is to be able to render client-side for users that have JavaScript enabled to to render the same templates/data server side for those users (and crawlers) that don't.

要求


  1. 客户端渲染。

  2. 服务器端呈现(JVM支持出色的功能)。

  3. 合理地支持循环,条件,文本操作,部分,宏和扩展/ plugins。

  4. 活跃的大型用户社区。
  1. Client side rendering.
  2. Server side rendering (JVM support a nice-to-have).
  3. Reasonable support for loops, conditionals, text manipulation, partials, macros and extensions/plugins.
  4. Reasonably big/active community of users.

不令人满意的解决方案到目前为止找到的


  1. Mustache :支持服务器和客户端渲染,大型/活动社区,但是无逻辑模板似乎非常局限且痛苦。

  2. Node.js 加上下划线:像下划线这样的JS模板提供了我需要的所有模板灵活性,但是使用Node.js在服务器端渲染它们非常脆弱。 node.js是新的并且相当不稳定,并且其包管理(导出...)需要大量的hack才能正常工作。

  3. Google Closure模板:这些可编译为JS和Java,并具有我想要的许多功能。不幸的是,浏览Google网上论坛似乎缺少许多基本功能(例如循环访问关联数组)和制作自己的插件的文档非常稀疏而痛苦。而且,我无法确定在线社区中谁在使用它,Google不接受它的开源贡献,并且他们没有释放新功能的带宽。

  4. 同位素:用JS编写模板并使用 Johnson (用于Mozilla SpiderMonkey JS运行时的Ruby包装器)在服务器端呈现这些模板。似乎很有希望,但是该项目在6个月内没有任何提交。

  5. 带有 Liquid.js 的Liquid :Liquid模板语言看起来很棒,但是液态。 js项目似乎未经测试(没有在IE中进行测试!),没有文档,尚不清楚是否有人使用它,并且有一段时间没有进行更新。

  1. Mustache: supports server and client side rendering, big/active community, but the "logic-less" templates seem very restrictive and painful.
  2. Node.js plus underscore: JS templates like underscore provide all the template flexibility I need, but rendering them server-side using Node.js is VERY fragile. node.js is new and fairly unstable and its package management (exports...) requires lots of hacks for things to work properly.
  3. Google Closure Templates: these compile down to JS and Java and have a lot of the features I want. Unfortunately, browsing the Google groups, it looks like lots of basic features are missing (such as ability to loop over associative arrays) and the documentation for making your own plugins is very sparse and painful looking. Moreover, I can't tell who in the online community is using it, Google isn't accepting open source contributions for it, and they don't have the bandwidth to release new features.
  4. isotope: write templates in JS and use Johnson, a Ruby wrapper for the Mozilla SpiderMonkey JS runtime, to render those templates server side. Seems promising, but the project hasn't had commits in over 6 months.
  5. Liquid with Liquid.js: the Liquid templating language looks superb, but the liquid.js project seems to be untested (no testing in IE!), has no documentation, it's not clear if anyone uses it, and it hasn't been updated in a while.


推荐答案

我们最终选择了 dust。 js 。查看让JSP尘埃落定客户端模板丢弃了解更多信息。

We ended up picking dust.js. Check out Leaving JSPs in the dust and The client-side templating throwdown for more info.

这篇关于客户端和服务器端渲染的模板语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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