In all my pages I am loading the header with this script
:
<script>
$("header:first-of-type").load("./pages/common/header.handlebars");
</script>
But if I have a mustache expression such as:
//header.handlebars
{{#if msg}}
<h1 class="msg">{{msg}}</h1>
{{/if}}
The page will treat it as text and render it like {{#if msg}}...{{/if}}
.
Is there any alternative to jQuery.load() which could compile it? I've read the docs, but I am just starting out with Handlebars and JS+jQuery
in general, so any help regarding specifically what I have to type in place of $().load()
would be greatly appreciated.