问题
What is wrong here?
Haml::Engine.new('= image_tag("golfer.png")').render
image_tag is always undefined (ActionView::Helpers in not loaded). How can I fix that? Thx!
回答1:
I think I found the solution.
class TagHelper
include Singleton
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
end
puts Haml::Engine.new('= image_tag("golfer.png")').render(TagHelper.instance)
来源:https://stackoverflow.com/questions/4097642/rails-haml-engine-rendering