Yeah, that's how I'd do it.

- Nathan

s.ross wrote:
> If you define a helper that returns a hash, you can use it in your haml.
>
> Nathan, correct me if this is wrong:
>
> # Not sure what a and b are in this context, but, from your example:
>
> def class_helper(what)
>    return {:class => what.to_s if [a, b].include?(what)}
>    return {:class => 'default'}
> end
>
> %li{class_helper}
>    whatever you want here
>
> Yes?
>
>
> On Jul 21, 2007, at 10:44 AM, Vlad Rafeyev wrote:
>
>   
>> I want this:
>>
>> <%
>> if a
>>   classname = "a"
>> elsif b
>>   classname = "b"
>> else
>>   classname = "default"
>> end
>> %>
>>
>> %li {:class => classname}
>>
>> Is this possible?
>>
>> Thank you!
>>
>> On Jul 21, 7:17 pm, Evgeny <[EMAIL PROTECTED]> wrote:
>>     
>>> If all you need to do is cycle, then you can use the "cycle" helper.
>>> Like so:
>>>   - a.each do |item|
>>>     %li{ :class => cycle('style1','style2') } item
>>>
>>> On 7/21/07, Vlad Rafeyev <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
>>>       
>>>> Hello here :)
>>>>         
>>>> I have a little array inside template:
>>>>         
>>>> - a = %w{1 2 3}
>>>>         
>>>> and I have a list, which made out of this array:
>>>>         
>>>> - a.each do |i|
>>>>   %li
>>>>     a[i]
>>>>         
>>>> If I want to display item1 with style1, and item2 with style2, what
>>>> should I do? Where do I have to insert IF?
>>>>         
>>>> Thank you!
>>>>         
>>     
>
>
> >
>
>   


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

Reply via email to