7
可能性の重複:
How to outsource a template js to a different file when using Handlebars.jsアクセス(テンプレートを含む)
私はhandlebearsを使用しています。テンプレート本体には、次のようなテンプレートを含めることをお勧めします。
<script id="entry-template" type="text/x-handlebars-template">
template content
</script>
テンプレートの内容をsrc属性で使用し、テンプレート(大量)を別々のファイルに保存したいとします。
<script src="/path/to/my.template" id="entry-template" type="text/x-handlebars-template"></script>
質問にはどのようにアクセスするのですか?
$('script#entry-template').html() //returns ""
$('script#entry-template').text() //returns ""
ajax getを実行してファイルの内容を取得できますか? – Shmiddty
Thanx。検索で見つからなかった –
アイデアは、ブラウザstandartメカニズムを使用することです。 src属性を持つスクリプトタグを満たしている場合、それをロードします。か否か?私は$( 'head')を使ってテストしました。append( '