1
votes

We have been using Ember for our MVC app through version 1.9. Now, with 1.10 it appears as though we need node to precompile templates somehow on the client side before they are viewed in the application, is that correct?

Unfortunately, we work in a very restricted environment where node and npm are "coming", but we don't have them yet. We've simply been including the handlebars.js file with ember to make our app work at runtime. So my real question - is there a way for me to continue using the newest versions of handlebars (or HTMLbars) and ember within my app without the need for node?

Please let me know if I'm missing something. I read the blog post (http://emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html) and lots of other discussion on this topic and I can't seem to understand this enough to move forward. Thanks in advance for any clarification you provide.

1

1 Answers

3
votes

I am going to make a lot of assumptions based on my assuredly poor understanding of your question. Please forgive me if I am telling you things that are already known to you.

The ember.js script can't read a .hbs file natively. That goes the same if you are using <script type="text/x-handlebars"> to define your templates. Same deal: It must be translated into pure Javascript before Ember actually understands it.

This conversion can either happen on the client side (in browser), or it can be done ahead of time by you. If it is done on the client side, there are more dependencies that Ember requires than if that doesn't have to happen. This has always been true.

The only difference is that now, instead of that dependency being called handlebars.js, it is called ember-template-compiler.js.

People talking about Node, Grunt, or Ember-CLI are talking about tools that are used to ease the development process. Often these tools will crunch down all the Ember dependencies into one file that is already purely Javascript and doesn't need to reference any .hbs files.

Assuming you develop off of the starter kit available on the front page of emberjs.org, you can still keep upgrading your app as you have in the past and it should all work fine. Just download the new stater kit and remember to change your <script> tag in your index.html file to reference ember-template-compiler.js instead of handlebars.js.

To illustrate something similar to this:

<script src="js/libs/jquery-1.10.2.js"></script>
<script src="js/libs/handlebars.js"></script>
<script src="js/libs/ember.min.js"></script>
<script src="js/app.js"></script>

Becomes something like this:

<script src="js/libs/jquery-1.10.2.js"></script>
<script src="js/libs/ember-template-compiler.js"></script>
<script src="js/libs/ember.min.js"></script>
<script src="js/app.js"></script>

I hope I understood your question enough to help.