Canalización de activos de Ember.js "No se puede encontrar la plantilla"

I am having trouble getting my handlebars templates accessible in rails 3.1. I have the following controller:

Lead.Controllers.UrlSearch = Ember.Object.extend
  init: ->
    view = Ember.View.create
      controller: @
      urlSearchBinding: 'controller.url_search'
      templateName: 'app/templates/url_search/show'

On the rails side of things, I have a the following initialisation script in config/initializers/sprockets.rb

require 'sprockets/ember_handlebars'

Rails.application.assets.register_engine 'hjs', EmberHandlebars

My EmberHandleBars looks like this:

require 'tilt'
require 'json'

class EmberHandlebars < Tilt::Template
  def self.default_mime_type
    "application/javascript"
  end

  def prepare
  end

  def evaluate(scope, locals, &block)
    "Ember.TEMPLATES['#{scope.logical_path}'] = Ember.Handlebars.compile(#{data.to_json})"
  end
end

Finally, the template is located in:

app/assets/javascripts/app/templates/url_search/show.jst.hjs

In there error console, I get this 404 resource error:

GET
http://localhost:3000/assets/app/templates/url_search/show.hjs.js?body=1
404 (Not Found)

y también

Error: - Unable to find template "app/templates/url_search/show".

I am confused why it is looking for an hjs.js file when I have specified otherwise and why it cannot find the template.

¿Alguien puede ver lo que estoy haciendo mal?

preguntado el 01 de febrero de 12 a las 22:02

1 Respuestas

Changing the file extensions form .jst.hjs to just .hjs fixed the problem.

Respondido 04 Feb 12, 01:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.