image_tag is a helper defined by Rails. In order to use it in a Haml template that you're defining manually, you need to pass in an ActionView::Base object to that template. I'm not sure what the best way to get such an object in script/console is, though.
Why exactly are you trying to do this on the command line in the first place? On Sat, Jul 25, 2009 at 6:02 AM, viki <[email protected]> wrote: > > Hi all, > > I have problem about HAML rendring > > > I have following small test for haml rendering > > >> a = Coupon.first > => #<Coupon id: 16, template_id: 1, business_id: 2, tag_line: > "Tagline", > expirat > ion_date: "2009-07-21", disclaimer: "Disclaimer", estimated_value: > #<BigDecimal: > 67e1f0c,'0.123E3',4(12)>, created_at: "2009-07-22 13:56:31", > updated_at: > "2009-0 > 7-22 13:56:31", tag_line_font_style: "bold", tag_line_font_family: > "Arial", tag_ > line_font_size: 22, discount: "50% ", discount_font_style: "bold", > discount_font > _family: "Arial", discount_font_size: 22, product_or_service: > "Product/Service", > product_or_service_font_style: false, product_or_service_font_family: > "Arial", > product_or_service_font_size: 22, expiration_date_font_style: false, > expiration_ > date_font_family: "Arial", expiration_date_font_size: 22, text_color: > "white", b > ackground_color: "#201E9F"> > > > if i give following to console > > >> haml_engine = Haml::Engine.new("%h3 Avatar =image_tag( > Photo.find(t.busines > s.avatar_id).public_filename(:thumb), :width =>'80px', :height => > '80px')").rend > er(Object.new, :t => a) > > IT GIVES ----> > > => "<h3>Avatar =image_tag( > Photo.find(t.business.avatar_id).public_filename(:th > umb), :width =>'80px', :height => '80px')</h3>\n" > > -------------------------------------------------------------- > > BUT IF I GIVE > > >> haml_engine = Haml::Engine.new("=image_tag( > Photo.find(t.business.avatar_id). > public_filename(:thumb), :width =>'80px', :height => > '80px')").render(Object.new > , :t => a) > > > I got following error > > > NoMethodError: undefined method `image_tag' for #<Object:0x6ab04a4> > from (haml):1:in `render' > from > c:/ruby/lib/ruby/gems/1.8/gems/haml-2.2.1/lib/haml/engine.rb:167:in > `render' > from > c:/ruby/lib/ruby/gems/1.8/gems/haml-2.2.1/lib/haml/engine.rb:167:in > `instance_eval' > from > c:/ruby/lib/ruby/gems/1.8/gems/haml-2.2.1/lib/haml/engine.rb:167:in > `render' > from (irb):8 > from :0 > > > Why the image_tag is not executing here? > How to solve this problem? Please give me solution. > > > Thanks, > Vikas > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
