JS中的模板? [英] Templates in JS?

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

问题描述

我们都喜欢简单易懂的简单结构化代码。我们试图在外观和逻辑之间进行区分。例如,在PHP中,我们可以使用模板机制,即使用php标签创建一个html格式的文件,该文件使用一些预定义变量,可以通过逻辑可重用脚本使用。

All we like simple, structured code that is easy to comply with. We try to bring a difference between appearance and logics. In PHP, for instance, we can use a template mechanism, i.e. create an html-formatted file with php tags that uses some predefined variables that get ready for use through a logic resposible script.

JavaScript是否有一些模拟?

Is there some analog for JavaScript?

您使用哪些方法来创建某种类型的动态内容? (例如列表项,可以重复多次的复杂表格)

What methods do you use to create dynamic content of certain type? (For example list items, complex forms that can be repeated several times)

推荐答案

Underscore.js 具有简单的模板机制也是如此。 (而且我认为必须在每个javascript开发人员的工具箱中)。

Underscore.js has simple templating mechanism as well. (And I think it must be in every javascript developer's toolbox).

jQuery 虽然更复杂,但可能更有用(更新:但现在已被弃用)。

jQuery's is more sophisticated, though - and probably more useful (Update: but now is deprecated).

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

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