title: Manage templates in large SPA with Ember.js and ASP.NET MVC
body: <p>I am converting a good old ASP.Net website to a single page application using Ember.js in a ASP.NET Web API project.
  All the devs of my team and myself are pretty new to javascript. We spent the last 2 weeks learning the basis and comparing SPA frameworks. I apologize in advance if my question sounds stupid :)</p>
  
  <p>All the Ember tutorials I have found so far included all Handlebars templates into one single file. I assumed it would be pretty obvious to split them into separates files (*.hbs) when the time would come, but it's not. I might be totally missing something here, but I found about 4 ways to get my templates back when I need them. I'd like to know which method you would recommend:</p>
  
  <ol>
  <li><p>Concatenate and then inject all the template files when the app loads. I could write some C# code on the server-side that concatenates all the templates files into a single one when the app loads (i.e. each time a visitor enter the app). It seems odd to me, in terms of processing, but also because the generated HTML file will be pretty heavy.</p></li>
  <li><p>Load each template dynamically via Ajax when I need it. Pretty much what is done <a href="https://stackoverflow.com/questions/9469235/is-it-possible-to-load-a-handlebars-template-via-ajax">here</a>. I kinda like this solution even though I haven't tried it yet. It makes sense to me to get asynchronously a template when I need it instead of loading the entire app on the first load.</p></li>
  <li><p>Use the Bundling mechanism of Asp.Net MVC. I found stuff like <a href="https://github.com/Myslik/csharp-ember-handlebars" rel="nofollow noreferrer">csharp-ember-handlebars</a> to precompile the templates on the server-side and return them as a single javascript file. It works-ish but I feel like the precompiled file will become pretty heavy as I add new templates.</p></li>
  <li><p>Use Grunt with the plugin <a href="https://github.com/yaymukund/grunt-ember-handlebars" rel="nofollow noreferrer">grunt-ember-handlebars</a> to precompile the templates. I'm not familiar with Grunt but if I understand well all the devs working on the project will have to install Node.js + Grunt + learn how to use a command prompt + remember to run the command before each commit (if they modified a template). This is not obvious for the web designers. And adding grunt to the build actions will require the entire dev team (working on other projects) to have grunt on their machine (not acceptable).</p></li>
  </ol>
  
  <p>I need to find a simple and elegant solution to address this issue. My project is in a solution with 35 other projects and I cannot add too much complexity to the build, neither depend on unstable libraries. Maybe I have been too optimistic when I thought I could use Ember for my project. Any suggestion would be welcome!</p>