Question

I am new to learning Ember.JS but am seasoned enough when it comes to working with Ruby on Rails. I have a straight forward question regarding the use of handlebars, the templating framework that is used by EmberJS. A lot of the text that teaches EmberJS I'm seeing on creating templates requires the use of something like the following:

 <script type="text/x-handlebars" id="blog/post"> 
     // insert template here
  </script>

The id attribute here is critical for the framework.

Now my question is, trying to learn more of Ember in the real world, I'm taking a look at the Discourse project that's available on GitHub that's built entirely with Ember on the frontend. All of their templates omit the the <script> tag. I can't really find it anywhere unless I'm looking in the wrong place.

What I'm trying to learn here is when is it necessary, and when can it be omitted? Is there some trickery going on in the Discourse open source project that allows them to omit it in this particular case?

Was it helpful?

Solution

Check out their gem dependencies in discouse. It's a very customized Ember app and probably isn't the best thing to check out when starting out TBH.

If you use the gem called ember-rails it handles versions of ember, ember data, handlebars and jquery, it also hooks up the template id naming using filenaming and folder conventions and asset precompiliation phase for your automatically (using that good old Rails magic). It also hooks up all your comonents and models appropriately. It's very good. I use it daily on my project development.

FWIW I think the core team of Ember are shifting away from a ruby-world-focus more as time passes which makes complete sense. Irrespective of this, Rails makes a pretty good backend for ember.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top