mustache.js cli で {{> head}} 形式のパーシャルテンプレート読み込みする方法
npm install mustache などで mustache をいれて、
<html>
{{> header.html}}
<body>
本文
{{> footer.html}}
</body>
</html>
こういう html で、
#ls
template.mustache header.html footer.html
ファイルがこうあって、
# mustache var.json template.mustache
上記のように実行しても {{> header.html}} はまったく解決してくれない。
ソース見ると -p でファイル名をすべて指定する必要があり、かつ、{{> }} ではファイル名から mustache をのぞいた名前を期待してるようだったので
<html>
{{> header}}
<body>
本文
{{> footer}}
</body>
</html>
こういう html で、
#ls
template.mustache header.mustache footer.mustache
ファイル名の拡張子を mustache にして
# mustache var.json template.html -p header.mustache -p footer.mustache
のように渡せばうまくいきました。
また、サブディレクトリ配下においていも、basename を取られるので、 {{> partial/header}} とかは上手くいかない。