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

cassiuschen · 2014年04月07日 · 最后由 cassiuschen 回复于 2014年04月08日 · 2550 次阅读

比如我现在有~/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 不知道为啥,总之不加任何的就没问题…

需要 登录 后方可回复, 如果你还没有账号请 注册新账号