# Haml rendering problem

**URL:** <https://www.ruby-forum.com/t/haml-rendering-problem/172686>\
**Category:** Rails\
**Created:** [July 25, 2009, 2:51pm UTC](https://www.ruby-forum.com/t/haml-rendering-problem/172686 "2009-07-25T14:51:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [July 25, 2009, 2:51pm UTC](https://www.ruby-forum.com/t/haml-rendering-problem/172686/1 "2009-07-25T14:51:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [July 25, 2009, 7:04pm UTC](https://www.ruby-forum.com/t/haml-rendering-problem/172686/2 "2009-07-25T19:04:29Z")

</div>

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](http://groups.google.com/group/haml)  
).

Hope this helps.
