[英]Compiling all shtml files into one html file using SSI or grunt
I am trying to build a live styleguide for an existing project. 我正在尝试为现有项目构建实时样式指南。 As part of this I would like to include all the shtml widgets I have in one folder into a single html file.
作为其中的一部分,我想将一个文件夹中的所有shtml小部件都包含在一个html文件中。
The type of solution I am looking for would follow this kind of behaviour: 我正在寻找的解决方案类型将遵循以下行为:
The project is running with both grunt and SSIs through an express server, so there are a couple of options I guess. 该项目通过快递服务器同时运行grunt和SSI,因此我猜有两个选择。
I have found this package which does grunt includes, however much of this is above my level of knowledge, so I have failed to get anything to work. 我发现这个程序包确实包含很多东西,但是其中很多超出了我的知识水平,因此我什么都没做。
This is the code I have so far for my grunt file: 这是到目前为止我的grunt文件的代码:
includes: {
files: {
src: ['widgets/.shtml'], // Source files
dest: 'kitchen-sink', // Destination directory
flatten: true,
cwd: '.',
options: {
silent: true,
banner: '<!-- I am a banner <% includes.files.dest %> -->'
}
}
}
I can see how this might work with a single, named file, but to loop through a folder seems a much harder task. 我可以看到它如何与单个命名文件一起工作,但是遍历文件夹似乎是一项艰巨的任务。
Any suggestions for a possible solution are gladly welcome. 我们欢迎任何可能的解决方案的建议。
In the end I used the suggestion from Qualcuno to use grunt-html-build. 最后,我使用了Qualcuno的建议来使用grunt-html-build。 This works very well, I will potentially write another grunt task to write in the titles for the widgets on the page.
效果很好,我可能会编写另一个艰巨的任务,以编写页面上小部件的标题。
This was my final code: 这是我的最终代码:
htmlbuild: {
dist: {
src: 'kitchen_sink/kitchen-sink.shtml',
dest: 'prod/kitchen_sink/kitchen-sink.shtml',
options: {
sections: {
views: 'prod/templates/widgets/**/*.shtml',
templates: 'prod/templates/widgets/**/*.shtml'
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.