Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 访问下划线模板中的JADE变量_Javascript_Node.js_Underscore.js_Pug_Underscore.js Templating - Fatal编程技术网

Javascript 访问下划线模板中的JADE变量

Javascript 访问下划线模板中的JADE变量,javascript,node.js,underscore.js,pug,underscore.js-templating,Javascript,Node.js,Underscore.js,Pug,Underscore.js Templating,我正在传递当前用户id(已登录用户的用户id),如 现在这意味着my home.jade文件可以访问currentUser变量 我可以用翡翠般的颜色接触到这个 p= currentUser 但是我想通过内部的下划线模板来访问这个变量 script(type='text/template') 我该怎么做 如果它是内联的,那么您应该能够使用{}返回变量 所以你想要 script(type='text/template'). var template = _.template("<b

我正在传递当前用户id(已登录用户的用户id),如

现在这意味着my home.jade文件可以访问currentUser变量

我可以用翡翠般的颜色接触到这个

p= currentUser
但是我想通过内部的下划线模板来访问这个变量

script(type='text/template')

我该怎么做

如果它是内联的,那么您应该能够使用
{}
返回变量

所以你想要

script(type='text/template').
    var template = _.template("<b><%- value %></b>");
    template({value: "#{currentuser}"});
script(type='text/template')。
var-template=551;.template(“”);
模板({value:{currentuser}});
script(type='text/template').
    var template = _.template("<b><%- value %></b>");
    template({value: "#{currentuser}"});