gruntでテンプレート変数に基づいたconcat
HTMLをパーツごとに分割して開発して、最後にconcatして1つのファイルに統合したい状況になったのでサクッと書いてみました。
設定
template_concat: 'html/dest/index.html': 'html/src/index.html' 'html/dest/page-1.html': 'html/src/page-1.html'
各種HTMLファイル (page-1.htmlは割愛)
html/src/index.html
<%= module/header.html %> <%= module/content.html %> <%= module/footer.html %>
html/src/module/header.html
<html> <head> <title>My Home Page</title> </head> <body>
html/src/module/content.html
<p>Hello, World!</p>
html/src/module/footer.html
</body> </html>
出力
html/dest/index.html
<html> <head> <title>My Home Page</title> </head> <body> <p>Hello, World!</p> </body> </html>