Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails HAML engine rendering

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!

like image 590
xpepermint Avatar asked Jan 29 '26 10:01

xpepermint


1 Answers

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)
like image 158
xpepermint Avatar answered Feb 01 '26 04:02

xpepermint



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!