HTML 模板的良好资源打包程序?
我正在编写一个足够复杂的 Web 应用程序,它需要大量的 HTML 模板(特别是它们是下划线模板,但这部分并不重要)。
我真的希望能够编写如下所示的模板文件:
fooTemplate:
<div class="foo">
<div class="bar"><%=name %></div>
</div>
并将所有模板文件转换为如下所示的单个 JS 文件:
window.templates = {}
...
templates.fooTemplate = '<div class="foo"><div class="bar">...</div>';
理想的属性:
- 有某种方法来指定每个模板的名称
- 去掉不必要的 名称所有模板文件中的空格
- 将所有模板文件连接成一个单一的 JS 文件
- 监视目录并在文件更改时自动更新
有没有什么东西可以做这些事情?
I'm writing a web app that's complicated enough that it needs a large family of HTML templates (specifically they're underscore templates, but that part doesn't really matter).
I really want to be able to write template files that look like the following:
fooTemplate:
<div class="foo">
<div class="bar"><%=name %></div>
</div>
And have it turn all of my template files into a single JS file that looks like this:
window.templates = {}
...
templates.fooTemplate = '<div class="foo"><div class="bar">...</div>';
Ideal properties:
- Has some way to specify the name of each template
- Strips unnecessary whitespace from all template files
- Concatenates all template files into a single, monolithic JS file
- Watches a directory and auto-updates when files change
Is there anything out there does does any of these things?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不太可能找到一个可以完成您列出的所有操作的全面解决方案,不可避免地会“需要进行一些组装”(如果没有,我很想听听)。
You're unlikely to find a comprehensive solution that does everything you list, there will inevitable be "some assembly required" (if not, I'd love to hear about it).