template报错Syntax Error
example:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>debug-demo</title>
<script src="../dist/template.js"></script>
</head>
<body>
<h1>错误捕获(请打开控制台)</h1>
<script id="test" type="text/html">
{{2 a ba d}}
</script>
<script>
var html = '';
html = template('test', {
});
document.write(html);
</script>
</body>
</html>
控制台报错:
Template Error
<temp>
function anonymous($data,$filename) {'use strict';var $utils=this,$helpers=$utils.$helpers,$escape=$utils.$escape,a=$data.a,ba=$data.ba,d=$data.d,$out='';$out+=$escape(2 a ba d);
return new String($out);}
<filename>
test
<name>
Syntax Error
我把js修改如下:
<script>
var html = '';
html = template('test', {
a:'111',
ba:'234',
d:'566'
});
document.write(html);
</script>
为什么控制台还是提示相同的错误了?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
语法不对吧
那个2是什么?
with型的模板引擎通病,
你试试
{{'2' + a + ba + d}}
或者{{2}} {{a}} {{ba}} {{d}}