%title= condition ? val1 : val2 On Wed, Mar 31, 2010 at 7:53 PM, Brewster <brewster1...@gmail.com> wrote:
> right, i intended to include the 3rd value but it was a bit of a rush > post. > what would the proper syntax for "condition ? val1 : val2" be in haml? > > On Mar 31, 5:56 pm, Nathan Weizenbaum <nex...@gmail.com> wrote: > > A ternary operator has three components (hence the name): it's of the > form > > "condition ? value1 : value2", where value1 is used if condition is true, > > and value2 is used otherwise. In your example, you're missing value2. > > > > If you only have one value, you can do this: "%title= value if > condition". > > > > > > > > On Wed, Mar 31, 2010 at 5:39 PM, Brewster <brewster1...@gmail.com> > wrote: > > > i have been struggling with using an if statement in my haml markup. > > > > > in my layout i have: > > > > > -if controller.action_name == 'index' > > > = controller.action_name.titleize > > > > > however, i wanted to implement that inline in my title > > > > > %title= controller.action_name == 'index' ? > > > controller.action_name.titleize > > > > > the latter does not work, and i have tried a variety of different > > > syntaxes, but i am just not having any success. i am releatively new > > > to ruby, and a noob with haml, so hoepfully there is something obvious > > > i am overlooking. > > > > > thanks! > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Haml" group. > > > To post to this group, send email to h...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > haml+unsubscr...@googlegroups.com<haml%2bunsubscr...@googlegroups.com>< > haml%2bunsubscr...@googlegroups.com<haml%252bunsubscr...@googlegroups.com> > >. > > > 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 h...@googlegroups.com. > To unsubscribe from this group, send email to > haml+unsubscr...@googlegroups.com <haml%2bunsubscr...@googlegroups.com>. > 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 h...@googlegroups.com. To unsubscribe from this group, send email to haml+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/haml?hl=en.