Definitely. Helpers aren't just for abstracting out frequently-used
patterns; they're for making views cleaner.
- Nathan
Ivan wrote:
> Damn, I knew I was missing something simple, hehe.
>
> Is it advisable to use a helper even if I will only use that code just
> once?
>
> Thanks.
>
> On Aug 3, 8:29 pm, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
>
>> Yes; that syntax will work, but you need a pipe character at the end of
>> each line, even the last. We advise you not to use this syntax at all,
>> though; it's generally a better idea to use a helper if you have a
>> method call that's too big to express concisely. This helps keep your
>> views clean and readable. For example:
>>
>> def logo_link
>> link_to image_tag('logo.gif', :size => '120x120', :alt => 'Site Logo'),
>> root_path, :id => 'site_logo'
>> end
>>
>> = logo_link
>>
>> - Nathan
>>
>> Ivan wrote:
>>
>>> Hi,
>>>
>>> I'm trying to do something like this, but apparently it's not
>>> possible:
>>>
>>> = link_to(image_tag 'logo.gif', {:size => '120x120', :alt => 'Site
>>> Logo'}), |
>>> root_path, |
>>> {:id => 'site_logo'}
>>>
>>> I get a syntax error. Am I doing this incorrectly?
>>>
>>> Thanks!
>>>
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---