服务器端的 jQuery 模板
有没有人尝试在服务器上使用 jQuery 模板 (或任何其他基于 JavaScript 的模板)与诸如 env.js 之类的东西站在一边?
我正在考虑尝试它,看看通过在 Web 应用程序的客户端或服务器端呈现相同的模板可以获得什么好处,但我希望有人可能已经有一些经验,或者知道现有的项目正在做这。我特别有兴趣了解与一些更传统的模板引擎相比我可能遇到的任何性能问题。
回顾一下:有人曾经在服务器站点上使用过 jquery 模板吗?如果是这样,是否存在任何性能问题或我可能遇到的其他问题?
Has anyone tried to use jQuery templates (or any other JavaScript based templating) on the server side with something like env.js?
I'm considering attempting it to see what benefits could be gained by being able to render identical templates on either the client or server side of a web application, but I was hoping someone might already have some experience, or know of an existing project doing this. I'd be particularly interested to know about any performance issues I might encounter compared to some more traditional templating engine.
To recap : Has anyone ever used jquery templates on the server site? If so, were there any performance issues, or other problems I might run into?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
env.js
是不必要的。我正在规范和重新实现 JQuery 模板,以允许它们独立于 DOM 使用。请参阅https://github.com/mikesamuel/jquery-jquery-tmpl-proposal 用于代码和演示。该规范位于 http://wiki.jqueryui.com/w/page/37898666 /Template 它说:
我希望获得反馈并可以帮助您入门。
env.js
is unnecessary.<plug shameless="true">
I am in the process of specing and re-implementing JQuery templates to allow them to be used independently of the DOM. See https://github.com/mikesamuel/jquery-jquery-tmpl-proposal for code, and demos. The spec is available at http://wiki.jqueryui.com/w/page/37898666/Template and it says:
I would love feedback and can help you get started.
</plug>
我的一位朋友从事分布式遗传编程项目,他使用 js sevrer 端模板系统来管理所有用户浏览器上生成的所有 Web Worker。他的代码在这里:github。我不知道它会有多大帮助,但我知道它实施起来非常简单,并且做了一些令人惊奇的事情。从他发现它有多容易我会推荐一个 js 模板系统。
A friend of mine working on a distributed Genetic Programing project used a js sevrer side template system to manage all the web workers spawned across all users browsers. His code is here: github. I don't know how helpful it will be, but I know it was quite simple to implement and did some amazing things. From how easy he found it I would recommend a js template system it.
编写服务器端代码来处理 jQuery 模板相当简单。
这是我创建的一些非常基本的vb.net代码,它将返回jquery 模板字符串的结果到任何对象的数组。目前它只替换数据值
所以如果我发送以下内容...
它会将其输出为字符串
这比在服务器上生成一个假浏览器对象并运行整个 jQuery 库要快得多替换一些标签。
It's fairly trivial to write server side code to process the jQuery templates.
Here is some very basic vb.net code I have created that will return the result of a jquery template string to an array of any objects. Currently it only does the replacement of data values
So if I sent in the following...
It would output it as a string
This will work alot faster than spawning up a fake browser object on the server, and running the whole jQuery library just to replace a few tags.