I have a fairly basic question.
I am learning Ember.js to be used with a Rails backend. I can get things to work when templates are mentioned inline in the HTML file.
<script type="text/x-handlebars" id="index">
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<table class='table'>
<thead>
<tr><th>Recent Posts</th></tr>
</thead>
{{#each item in model}}
<tr><td>
{{item.name}}
</td></tr>
{{/each}}
</table>
</div>
<div class="span9">
{{outlet}}
</div>
</div>
</div>
</script>
But the minute I moves this snippet to a .hbs file under templates directory, and include the following line in my application.js file,
#= require_tree ./templates
they fail with this error.
Assertion failed: You specified the templateName cms2/index for <CMS.IndexView:ember229>, but it did not exist.
I have tried to precompile then using two different Rubygems,
gem 'handlebars_assets'
and
gem 'ember-rails'
From what I read, those two gems are supposed to precompile all .hbs files and including the templates directory tree should fix this problem.
What am I missing? Why isn't this working for me?
Thanks.
Did you turn on the Ember support in Handlebars Assets?
HandlebarsAssets::Config.ember = true
This will add the templates to the Ember.TEMPLATES namespace so they can be resolved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.