[Rails] Re: Display Block Conditionally

2009-07-02 Thread graeme-d
Doug, I recall I went through a similar 'wow' experience, and it helped me sort out how this was working when I realised I could think of <% and %> in the reverse of the way they are normally presented. By that I mean, insted of seeing a <% %> pair as bracketing ruby code embedded in the middle

[Rails] Re: Display Block Conditionally

2009-06-21 Thread s.ross
On Jun 21, 2009, at 9:48 AM, Marnen Laibow-Koser wrote: > > Tonypm wrote: >> steve >> >> that's the first outline of erb I have seen. Glad to be of help. >> > > Yes, thanks for that. I know intuitively how ERb works, but had never > looked at the internals in any detail. > > [...] >> I >> u

[Rails] Re: Display Block Conditionally

2009-06-21 Thread Marnen Laibow-Koser
Tonypm wrote: > steve > > that's the first outline of erb I have seen. Yes, thanks for that. I know intuitively how ERb works, but had never looked at the internals in any detail. [...] > I > use haml, and I have often wondered how it hooks into erb. As far as I know, it doesn't (unless yo

[Rails] Re: Display Block Conditionally

2009-06-20 Thread Tonypm
steve that's the first outline of erb I have seen. Either it doesn't get discussed a lot, or it is discussed in places I don't visit. Anyway, although I had a broad idea of what was going on under the bonnet, I had never really seen a clear example of an erb template in action. I use haml, and

[Rails] Re: Display Block Conditionally

2009-06-20 Thread djolley
> "_erbout = '' > _erbout.concat \"This is plain text\\n\"\n_erbout.concat \"And the > time is \" > _erbout.concat(( Time.now ).to_s) > _erbout.concat \"\\n\"\n > if true >_erbout.concat \"\\n\"\n_erbout.concat \" it was true\\n\"\n > else >_erbout.concat \"\\n\"\n_erbout.concat \" it wa

[Rails] Re: Display Block Conditionally

2009-06-19 Thread s.ross
On Jun 19, 2009, at 11:51 AM, djolley wrote: > > Thanks so much for your kind explanation. Unfortunately, it still > doesn't make sense to me. > > The documentation for the ERB class tells us: > > <% Ruby code -- inline with output %> > <%= Ruby expression -- replace with result %> > > That make

[Rails] Re: Display Block Conditionally

2009-06-19 Thread Colin Law
2009/6/19 djolley : > > Thanks so much for your kind explanation.  Unfortunately, it still > doesn't make sense to me. > > The documentation for the ERB class tells us: > > <% Ruby code -- inline with output %> > <%= Ruby expression -- replace with result %> > > That makes perfect sense.  The docu

[Rails] Re: Display Block Conditionally

2009-06-19 Thread djolley
Thanks so much for your kind explanation. Unfortunately, it still doesn't make sense to me. The documentation for the ERB class tells us: <% Ruby code -- inline with output %> <%= Ruby expression -- replace with result %> That makes perfect sense. The documentation even alludes to the capabil

[Rails] Re: Display Block Conditionally

2009-06-18 Thread s.ross
On Jun 18, 2009, at 10:03 PM, djolley wrote: > >> Not sure what you mean by conditionally... if it's something server >> side you could just do: >> >> <% if this_expression_evaluates_to_true %> >> put your html here >> <% end %> > > That is exactly what I'm talking about and it gives me a great

[Rails] Re: Display Block Conditionally

2009-06-18 Thread djolley
> Not sure what you mean by conditionally... if it's something server > side you could just do: > > <% if this_expression_evaluates_to_true %> >put your html here > <% end %> That is exactly what I'm talking about and it gives me a great basis for trying to articulate what is confusing me. I

[Rails] Re: Display Block Conditionally

2009-06-18 Thread Colin Law
2009/6/18 doug : > > I have seen a number of examples where HTML code is treated as a Ruby > block. For example, here is one taken from the Agile Rails book: > > <% content_for( :sidebar) do %> >   >      this text will be rendered >      and saved for later >      it may contain <%= "dynamic" %>

[Rails] Re: Display Block Conditionally

2009-06-18 Thread Frederick Cheung
On Jun 18, 8:27 pm, doug wrote: > I have seen a number of examples where HTML code is treated as a Ruby > block. For example, here is one taken from the Agile Rails book: > > <% content_for( :sidebar) do %> >   >       this text will be rendered >       and saved for later >       it may conta

[Rails] Re: Display Block Conditionally

2009-06-18 Thread Philip Hallstrom
> I have seen a number of examples where HTML code is treated as a Ruby > block. For example, here is one taken from the Agile Rails book: > > <% content_for( :sidebar) do %> > > this text will be rendered > and saved for later > it may contain <%= "dynamic" %> stuff > > <% end %