JavaScript库语法的机制和含义:${value}
我在O'Reilly的文章中遇到了以下JavaScript代码片段 JavaScript Web应用程序:JavaScript库语法的机制和含义:${value},javascript,templates,Javascript,Templates,我在O'Reilly的文章中遇到了以下JavaScript代码片段 JavaScript Web应用程序: // helper.js var helper = {}; helper.formatDate = function(){ /* ... */ }; // template.html <div> ${ helper.formatDate(this.date) } </div> //helper.js var-helper={}; helper.formatD
// helper.js
var helper = {};
helper.formatDate = function(){ /* ... */ };
// template.html
<div>
${ helper.formatDate(this.date) }
</div>
//helper.js
var-helper={};
helper.formatDate=函数(){/*…*/};
//template.html
${helper.formatDate(this.date)}
但是,此处未提供对任何特定JavaScript库的引用。
${…}语法的可能含义是什么?它是如何工作的?
这是否来自使用任何特定的库?我见过
jQuery的$()表示法,其中$是一个函数,但我还没有看到
$后跟一对花括号
谢谢。它可能来自旧版本,不再处于开发阶段或其他模板引擎:
template.html
中的一个占位符。好吧,令人费解的是,一旦函数返回,我希望看到类似${2003-04-05}或类似的东西,看起来不像变量名。一个日期值怎么可能是一个合理的模板变量名呢?它可能确实是这样,但是否有一个继承者取代了使用相同语法等的已失效的jQuery Tmpl库?