これを処理する最も簡単な方法は、サーバー側のテンプレートで Mustache 区切り文字を変更することです。このようなもの:
{{=<% %>=}}
<html>
<head>
<title><% title %></title>
<script type="text/x-handlebars-template" id="mytemplate">
{{# stuff }}{{ otherstuff }}{{/ stuff }}
</script>
</head>
<body>
<h1><% title %></h1>
</body>
</html>
こうすることで、<%
Mustache.php で型区切り文字が使用され、{{
型区切り文字が無視され、Handlebars.js で確実に使用できるようになります。
通常の区切り文字に Mustaches を使用し続けたい場合は、Handlebars テンプレートの前後の区切り文字をすぐに変更することもできます。
<html>
<head>
<title>{{ title }}</title>
{{=<% %>=}}
<script type="text/template" id="mytemplate">
{{# stuff }}{{ otherstuff }}{{/ stuff }}
</script>
<%={{ }}=%>
</head>
<body>
<h1>{{ title }}</h1>
</body>
</html>
ハンドルバー テンプレートをパーシャルに移動する場合:
{{=<% %>=}}
<script type="text/template" id="mytemplate">
{{# stuff }}{{ otherstuff }}{{/ stuff }}
</script>
... デリミタの変更は、そのパーシャル内でのみ適用されます。次に、これを行うことができます:
<html>
<head>
<title>{{ title }}</title>
{{> handlebars_templates }}
</head>
<body>
<h1>{{ title }}</h1>
</body>
</html>
この方法が最もメンテナンスしやすいので、この方法をお勧めします。