Javascript - 模板引擎
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12348037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript - Template Engine
提问by Cybermaxs
Nowadays, we can find many JS templating engines like KnockOut, Mustache, Underscore, ... Can you please tell me what are the advantages of an architecture based upon theses engines ? and/or when to use them ? Is it better (maintainability, dev costs, reliability, ...) than generating all HTML from server-side ?
如今,我们可以找到许多 JS 模板引擎,例如 KnockOut、Mustache、Underscore 等……您能告诉我基于这些引擎的架构有什么优势吗?和/或何时使用它们?是否比从服务器端生成所有 HTML 更好(可维护性、开发成本、可靠性等)?
Is it a good architecture to expose feeds (rest service in json) and do some stuff on client side (micro templating) ?
公开提要(json 中的休息服务)并在客户端(微模板)做一些事情是一个很好的架构吗?
回答by Fatih Acet
Linkedin has done great research, have a look at this page.
Linkedin 做了大量的研究,看看这个页面。
回答by MichaelT
The main advantage of templates is optimization of the amount of data passed to the client it make response faster, reduces your traffic costs, and increase throughput of your servers.
模板的主要优点是优化了传递给客户端的数据量,从而加快了响应速度、降低了流量成本并提高了服务器的吞吐量。