I was wondering whether someone could show me how to dynamically set the the 'id' attribute in the 'body' tag. I would like to set the id to controller name (in lowercase) using embedded ruby.
<body id="xxxx"> </body>
cheers </jima>
I was wondering whether someone could show me how to dynamically set the the 'id' attribute in the 'body' tag. I would like to set the id to controller name (in lowercase) using embedded ruby.
<body id="xxxx"> </body>
cheers </jima>
I was wondering whether someone could show me how to dynamically set the the 'id' attribute in the 'body' tag. I would like to set the id to controller name (in lowercase) using embedded ruby.
<body id="xxxx"> </body>
<body id="<%= controller.controller_name -%>">
Regards, Rimantas
thxs Rimantas. Just tried it and it works a treat. So basically i can place <%= %> expression anywhere within quotes and it will get evaluated before generating the XHTML.
cheers </jima> Rimantas Liubertas wrote:
thxs Rimantas. Just tried it and it works a treat. So basically i can place <%= %> expression anywhere within quotes and it will get evaluated before generating the XHTML.
Well, in this case it just happen that you need to have output something between quotes. In templates you can use ERB wherever you need. You may want to read ERB section here http://api.rubyonrails.com/classes/ActionView/Base.html and also "Recognized tags" http://stdlib.rubyonrails.org/libdoc/erb/rdoc/classes/ERB.html This should give you a general idea, how it works. Keep in mind that second link is to the general documentation of ERB, not rails specific.
Regards, Rimantas