0
votes

My question is very simple although I couldn't find a way to do it.

I basically want to have all of my handlebars templates external. Here is a sample template file of mine. It is called example.js

<script id="test_template">
<div>Hello world!</div>
</script>

When I include it in the html file I get the following error:

Uncaught SyntaxError: Unexpected token < 

For the first line - the browser isn't happy that there is some html in the javascript source file.

My qustion is: what way is there arround it / What is the standard ways to split templates into files in handlebars ?

1

1 Answers

0
votes

Inside a file, add type="text/x-handlebars-template"

<script type="text/x-handlebars-template" id="test_template">
    <div>Hello world!</div>
</script>

For an external file, look: https://github.com/wycats/handlebars.js/issues/82