I often do this with
%input{ :checked => (@task.completed? "checked": nil) }
On 21 Aug 2010, at 16:23, DAZ wrote:
> Hi,
>
> I'm trying to conditionally tick a checkbox based on whether a task is
> completed or not, using the ternary syntax:
>
> This works in erb:
> <input id="completed" name="completed" type="checkbox" value="done" <
> %= @task.completed ? "checked" : "" %>/>
>
> This is what I tried in Haml, but got a syntax error of 'Invalid
> attribute list':
>
> %input#completed(name="completed" type="checkbox" value="done"
> #[email protected] ? "checked" : ""})
>
> Any suggestions?
>
> cheers,
>
> DAZ
>
>
> --
> 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.
>
--
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.