Dominic Son
2006-Jul-13 14:47 UTC
[Rails] From the Agile book, page 144 regarding a div tag helper
Hi. in the Rails Agile book here''s what was happening:
>>>
module StoreHelper
def hidden_div_if(condition, attributes = {})
if condition
attributes["style" ] = "display: none"
end
attrs = tag_options(attributes.stringify_keys)
"<div #{attrs}>"
end
# format_price method ...
end
Note that we cheated slightly here. We copied code from the Rails
standard
helper called content_tag( ); that?s how we knew to call tag_options( )
the way
we did.And how did we find the source code of the content_tag( ) method?
We brought up the
RDoc documentation in a browser and clicked the View Source
link.>>>
This just flew gracefully over my head..(duuugh)..
I was at the RDDoc site, and nothing pertaining to helper methods, or a
source containing ''content_tag()'' was found..
So my question is which source file did Dave talk about? and how often
would we have to do this kind of trick..
Thanks
--
Posted via http://www.ruby-forum.com/.
Dan Kohn
2006-Jul-13 15:32 UTC
[Rails] From the Agile book, page 144 regarding a div tag helper
It''s a listed method on the main page.
http://api.rubyonrails.com/classes/ActionView/Helpers/
TagHelper.html#M000489
- dan
--
Dan Kohn <mailto:dan@dankohn.com>
<http://www.dankohn.com/> <tel:+1-415-233-1000>
On Jul 13, 2006, at 7:44 AM, Dominic Son wrote:
> Hi. in the Rails Agile book here''s what was happening:
>>>>
> module StoreHelper
> def hidden_div_if(condition, attributes = {})
> if condition
> attributes["style" ] = "display: none"
> end
> attrs = tag_options(attributes.stringify_keys)
> "<div #{attrs}>"
> end
> # format_price method ...
> end
>
> Note that we cheated slightly here. We copied code from the Rails
> standard
> helper called content_tag( ); that?s how we knew to call tag_options
> ( )
> the way
> we did.And how did we find the source code of the content_tag( )
> method?
> We brought up the
> RDoc documentation in a browser and clicked the View Source link.
>>>>
>
> This just flew gracefully over my head..(duuugh)..
>
> I was at the RDDoc site, and nothing pertaining to helper methods,
> or a
> source containing ''content_tag()'' was found..
>
> So my question is which source file did Dave talk about? and how often
> would we have to do this kind of trick..
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails