node.js 的模板引擎 [英] Template engine for node.js

查看:46
本文介绍了node.js 的模板引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道最好的 node.js 模板引擎.目前我在 node.js 中使用 jade 引擎.

I would like to know the best template engine for node.js. Currently I'm using jade engine with node.js.

读完这篇文章后出现了困惑

The confusion arise after reading this

https://github.com/baryshev/template-benchmark

请给我推荐最好的

谢谢.

推荐答案

没有最好的视图引擎.最佳视图引擎的标准基于模板引擎必须实现的实际需求以及使用它的人.例如,很多人真的很喜欢 Jade 视图引擎,但也有很多人认为它不好,因为他们不喜欢它的语法.您应该遵循的优先事项很简单:

There is no best view engine. The criteria to a best view engine is based on the actual needs the template engine has to realize and the person(s) using it. A lot of people really love the Jade view engine, for example, but there are many that do not consider it good because they do not like the syntax. The priorities you should follow are simple:

  1. 语法:您喜欢视图引擎为您提供的语法吗?
  2. 功能:视图引擎是否具备您希望它执行的所有功能(例如包含、变量、过滤器)?
  3. 学习:学习难吗?如果你有设计师,他们懂吗?工具?
  4. 社区:是否有可以帮助解决问题的社区或可联系的人?
  5. 性能:视图引擎是否编译和缓存?如果不是,这真的重要吗?
  1. Syntax: Do you like the syntax the view engine has for you?
  2. Features: Does the view engine have everything you want it to do (e.g. includes, variables, filters)?
  3. Learning: Is it hard to learn? If you have designers, do they understand it? Tooling?
  4. Community: Is there a community, or someone reachable, that can help with problems?
  5. Performance: Does the view engine compile and cache? If not, does this really matter?

请注意,当您在生产模式下运行 node 时,大多数视图引擎会自动进入编译和缓存(NODE_ENV=production)现在您应该只检查不同风格的视图引擎,并根据您的标准决定您最喜欢什么项目(例如 Jade、Handlebars、EJS、Gaikan).

Note that most view engines automatically fall to compilation and caching when you run node in production mode (NODE_ENV=production) Now you should just check out different flavours of view engines and decide on what you like best according to the criteria of your project (e.g. Jade, Handlebars, EJS, Gaikan).

更新:我查看了基准测试并决定将我自己的视图引擎合并到其中(Gaikan).可以在这个地址看到分叉 https://github.com/Deathspike/template-benchmark包括结果.如果您完全是为了性能,这会增加另一个有价值的选择,但我建议您坚持我上面列出的优先事项.

Update: I looked at the benchmarks and decided to merge my own view engine into it (Gaikan). The fork can be seen at this address https://github.com/Deathspike/template-benchmark including the results. If you are completely for performance, this adds another valuable option, but I would recommend to stick to the priorities I listed above.

这篇关于node.js 的模板引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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