Haml rendering problem

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 ---->

=> “

Avatar =image_tag(
Photo.find(t.business.avatar_id).public_filename(:th
umb), :width =>‘80px’, :height => ‘80px’)

\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:inrender’
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:ininstance_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

Hi–
On Jul 25, 2009, at 5:51 AM, Vikas G. wrote:

“Tagline”,
_family: “Arial”, discount_font_size: 22, product_or_service:
if i give following to console
Photo.find(t.business.avatar_id).public_filename(:th
, :t => a)
from
How to solve this problem? Please give me solution.

I can’t tell from the formatting whether your haml is correct, but the
reason you aren’t finding image_tag from the console is probably that
you don’t have the ActionView helpers included. Look up image_tag and
then include the fully-qualified module for image_tag and try again.
You might also try posting to the Haml Google Group
(http://groups.google.com/group/haml
).

Hope this helps.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs