May I ask *why* you want logic in your view?

Coming from RHTML, it seems natural to do. Haml encourages separating  
it into helpers that can be tested in isolation instead of by side- 
effect. Once you start doing that, you may discover you have the same  
need in several places in your application. One helper function, one  
set of tests, many places where it can be used.

--s

On Jul 21, 2007, at 12:56 PM, Vlad Rafeyev wrote:

>
> Thank you, I wanted exactly this
>
> But is there a way not to put "-" in the beginning of every pure ruby
> line? Maybe set the beginning and the end of "pure ruby" script?
>
> RHTML templates have this possibility :)
>
> On Jul 21, 8:50 pm, Jens-Christian Fischer <[EMAIL PROTECTED]>
> wrote:
>>> I want this:
>>
>>> <%
>>> if a
>>>   classname = "a"
>>> elsif b
>>>   classname = "b"
>>> else
>>>   classname = "default"
>>> end
>>> %>
>>
>>> %li {:class => classname}
>>
>>> Is this possible?
>>
>> The HAML purity gurus would probably tell you to put this into a
>> helper, but if you want to do it inside HAML, it would look like  
>> this:
>>
>> - a.each do |n|
>>    - if n == "x"
>>      - classname = "a"
>>    - elsif ...
>>      - classname = "b"
>>    - ...
>>    %li{ :class => classname }
>>
>> I would also go for a helper...
>>
>> cu jc
>
>
> >


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