I solved this by naming my Tag instance variables @t and the haml template t.haml. It's the instance variable @tag that's the real culprit and it's easy enough to get around it. No need to resort to ERb. ;)
RSL On 6/17/07, DD.Jarod <[EMAIL PROTECTED]> wrote: > > > Hi, > I ran into a problem with a template named _tag.haml this day. I > searched this group and found some post with a related (maybe the > same?) problem, but no solution: > 'Strange Haml Interference with @tags or Tag.find(:all)' > http://groups.google.com/group/haml/browse_thread/thread/9d37159348fc0c52 > I tried to reply to the post, but I was unable to do that, so I made a > new one. > > Currently I ran Version 1.5.2 of haml within rails, and now to the > point: > Like Russel Norris, I have a model named 'Tag' too, and at some point > in the code, I use a template for instances of Tag: > > # .../views/.../list.haml > [...] > #content > =render :partial => @selection.to_s.downcase, :collection => > @content > [...] > > in which @selection is either Tag or Feed (both are instance of Class, > representing models) and @content is an array of instances of either > Tag or Feed. Within the _feed.haml template all went good. And here is > the _tag.haml template: > > # .../views/.../_tag.haml > .tag > .icon= image_tag 'unknown.png' unless tag.icon == '' > .name= tag.name > .tag_new= tag.tag_new? ? 'Y' : 'N' > > what happens is, that the rails helper image_tag gets screwed up. It > produces something like: > <div class='tag'> > <div class='icon'>#<Tag:0xb6880d7c></div> > <div class='name'>12345</div> > <div class='tag_new'>N</div> > </div> > > whereas the following rhtml code (after removing the _tag.haml file) > > # .../views/.../_tag.rhtml > <div class='tag'> > <div class='icon'><%= image_tag 'unknown.png' unless tag.icon == > ''%></div> > <div class='name'><%= tag.name%></div> > <div class='tag_new'><%= tag.tag_new? ? 'Y' : 'N'%></div> > </div> > > is producing > <div class='tag'> > <div class='icon'><img alt="Unknown" src="/images/unknown.png? > 1182104186" /></div> > <div class='name'>12345</div> > <div class='tag_new'>N</div> > </div> > > Until now, I havn't found another problem with the Tag model. I will > stick with the rhtml at the moment, it's not THAT ugly (... ok, it > is :). > I hope that helps with fixing the bug, or finding a workaround. > > btw I tried > .icon= self.send(:image_tag, 'unknown.png') unless tag.icon == '' > in the _tag.haml template, which resulted in the same error. > > ~ Jarod > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
