【发布时间】:2014-06-18 02:06:16
【问题描述】:
我正在尝试找出一种简单的方法来在脚本中要求一个 html 模板,然后从 CLI 运行 browserify。
假设我想获取一个模板并将其附加到正文中。
//index.js
var template = require('./template.html');
document.body.appendChild(template);
和
<!-- template.html -->
<p>Woooo!</p>
然后使用 CLI 将其全部打包到 Browserify 中。
browserify index.js > build.js
在浏览器中加载引用 build.js 的 index.html 模板时,我在控制台中收到此错误:
Uncaught SyntaxError: Unexpected token <
引用
....
},{}],3:[function(require,module,exports){
<div class="slide">
<h2 data-slide-title></h2>
<div data-slide-copy></div>
</div>
},{}]},{},[1])
【问题讨论】:
标签: javascript browserify commonjs