Thanks. I just wanted to make sure I wasn't missing anything. It's a rare
and dubious need, but I was curious.

On Wed, Jun 17, 2009 at 1:55 PM, Nathan Weizenbaum <[email protected]> wrote:

> The helper is the best solution for the form_for case; Adam's class
> solution is what I'd use for the class-name case.
>
>
> On Wed, Jun 17, 2009 at 9:15 AM, Adam Hooper <[email protected]>wrote:
>
>>
>> On Wed, Jun 17, 2009 at 11:36 AM, Nicholas Van
>> Weerdenburg<[email protected]> wrote:
>> > I created the following helper:
>> >   def xhr_form_for *args, &block
>> >     if request.xhr?
>> >       remote_form_for *args, &block
>> >     else
>> >       form_for *args, &block
>> >     end
>> >   end
>> > To allow dynamic selection of form type based on whether the page is an
>> AJAX
>> > request or not.
>> > Is there a way to do this outside of a helper? Not that I wish to do
>> evil
>> > and break any rules, but I'm curious for my understanding of HAML.
>>
>> Personally, I don't see this problem in my code, because:
>> - I never use remote_form_for, since unobtrusive JS works even better
>> - Usually my forms are in a separate partial (e.g.,
>> "app/views/articles/_form.html.haml") so there's not much to indent
>> anyway.
>>
>> Neither is a reason for you to remove your helper; I just thought I'd
>> point out my general observation that indenting issues such as this
>> one do not cause many problems in the context of what I consider to be
>> programming best-practices.
>>
>> (Incidentally, your helper makes ERB code much cleaner: if you used it
>> in ERB, you still wouldn't need icky indentation tricks.)
>>
>> > The above may not work because of the block, but a similar case
>> > is:
>> > -if color==:blue
>> >   .blue_div
>> > -else
>> >    .red_div
>> > Is there a way to indent under the red div without using a helper?
>>
>> This is a very common situation:
>>
>> %div{:class => (color == :blue ? 'blue_div' : 'red_div')}
>>
>> IMO the one-line syntax is better: it keeps the document structure
>> perfectly clear. (You can throw in helpers or local variables to
>> improve the legibility of that one line.)
>>
>> Adam
>>
>> --
>> My Website: http://adamhooper.com
>> My Blog: http://adamhooper.com/blog
>>
>>
>>
>
> >
>

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