新手问题 如何在 AngularJS 中使用 slim 渲染 template?

cassiuschen · April 07, 2014 · Last by cassiuschen replied at April 08, 2014 · 2550 hits

比如我现在有~/app/assets/templates/home.html.slim,然后在某.js.coffee.erb中有写:

window.App.config ['$routeProvider', ($routeProvider) ->
    $routeProvider
        .when '/',
            templateUrl: "<%= asset_path 'home.html' %>"
]

然后很明显 Rails 找不到 home.html…… 有在~/config/initializers/render.rb中写:

Rails.application.assets.register_engine('.slim', Slim::Template)

Rails.application.assets.context_class.class_eval do
  include ActionView::Helpers
  include Rails.application.routes.url_helpers
end

但依然找不到……求大大帮助…………

templates/home.html

#1 楼 @winnie 依然找不到>~<我在 application.rb 中写了

config.assets.paths << Rails.root.join("templates")

应该没有问题昂>~<

#1 楼 @winnie 啊谢谢!解决了!就是因为多写了这么一句= =!

config.assets.paths << Rails.root.join("app/assets/templates") 这样试试

#4 楼 @winnie 不知道为啥,总之不加任何的就没问题…

You need to Sign in before reply, if you don't have an account, please Sign up first.