<body>
<script type="text/x-handlebars" data-template-name="index">
<h2>Welcome to Ember.js</h2>
<ul>
{{#each item in content}}
<li>{{item}}</li>
{{/each}}
</ul>
</script>
It seems like this would get unweildy for a large app. In my homegrown client side templating library I load the templates from a separate file (actually, from a lot of different source files that get combined and minified for production use). For big projects is there a standard way of doing this? How is Discourse doing it (I don’t see templates in view source here; I know it’s an open source project but I don’t know RoR and it seems tied up in erb sources…)?
Although this is perfectly acceptable, it’s recommended to bundle precompiled handlebars templates into JavaScript via Em.TEMPLATES["template/name"] = Em.Handlebars.compile('Template content goes here')
I’m not the best person to indicate how to do this in Rails; in .NET, however, I recommend using this library.
This does all the hard work for you. It creates a nice structure for you to put your handlebars templates under app/assets/javascripts/templates, and then pre-compiles the templates when building the asset pipeline.
I struggled myself with this question for quite some time. If you are using a backend framework like Rails @tsantos83 and @raul are absolutely right. For most frameworks there are working solutions which pre-compile Handlebar templates. Are you using any backend Framework?
If this is not the case, I encourage you to take a look at Cinder Plate (https://github.com/edgycircle/cinder-plate) . This is a skeleton for Brunch I specifically created for Ember.js development when you don’t use a backend. You get a nice structure for all your files, and it does a bunch of things for you. One of them is pre-compiling your templates. So maybe it’s the right thing for you.