Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to move my full-stack rails app over to Angular a page at a time. I'm using ui-router (https://github.com/angular-ui/ui-router) and angular-rails-templates (https://github.com/pitr/angular-rails-templates). I assumed the nghaml extension would allow me to continue to use rails helpers such as link_to, paths, etc. in my haml so just copied and pasted my haml page into the template; in an ideal world I would now be at a point where one page was being served client-side and every other page (including the ones it's linked to) were still being served server-side. Instead, I'm getting errors such as:

undefined local variable or method `dashboard_patients_path' for #<Object:0x007fc87865cff0>

and link_to, etc.

I thought this (angularjs with client side haml) would be a solid solution, specifically sharpper's response since it seemed directly applicable.

module CustomHamlEngine
  class HamlTemplate < Tilt::HamlTemplate
    def evaluate(scope, locals, &block)
      scope.class_eval do
        include Rails.application.routes.url_helpers
        include Rails.application.routes.mounted_helpers
        include ActionView::Helpers
      end

     super
    end
  end
end

Rails.application.assets.register_engine '.haml', CustomHamlEngine::HamlTemplate

However, even after restarting the server, no dice.

Thoughts?

share|improve this question
    
My first thought would be make sure this code is bring run with some log statements! :) Other than that Rails could have changed the way they write their engines. I would try to look for some resources on the Tilt engine in Rails today and see if anything stands out. –  sharpper Apr 10 at 22:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.