Rails HAML engine rendering

What is wrong here?

Haml::Engine.new('= image_tag("golfer.png")').render

image_tag is always undefined (ActionView :: Helpers are not loaded). How can i fix this? thank!

+3
source share
1 answer

I think I found a 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)
+2
source

Source: https://habr.com/ru/post/1773051/


All Articles