[Nitro] Using Facets Builder
transfire at gmail.com
transfire at gmail.com
Thu Feb 8 06:18:26 EST 2007
On Feb 8, 5:00 am, "George Moschovitis" <george.moschovi... at gmail.com>
wrote:
> It is an algternative way to generate html for your action. Here are two
> examples:
>
> # This is a programmatic renderer example. Just for
> # demonstration purposes. Some people tend to like this
> # aproach, dunno why, really.
>
> def prender
> build do |r|
> labels = ['George', 'Stella', 'Renos']
> r.html {
> r.head {
> r.title 'A simple test'
> }
> r.body {
> 10.times {
> r.strong 'Hello World'
> r.br
> r.i 'Hello World'
> r.br
> }
> r.select(:id => 'names') {
> r.options :labels => labels, :selected => 1
> }
> }
> }
> end
> end
>
> # The same example in different flavour :)
>
> def prender2
> build do
> labels = ['George', 'Stella', 'Renos']
> html {
> head {
> title 'A simple test'
> }
> body {
> 10.times {
> strong 'Hello World'
> br
> i 'Hello World222'
> br
> }
> select(:id => 'names') {
> options :labels => labels, :selected => 1
> }
> }
> }
> end
> end
>
> on a nutchell, build just returns a builder instance. Btw, do not change
> your implementation to be compatible with this, just make build return your
> builder instance. But please make sure that your implementation can be used
> in the form helper (this helper, unlike the build command, is used very
> often)
got it. thanks. the form helper is a bit odd b/c it has a secondary
builder inside of it. so i'm going to think about that --i'd like to
avoid the double layer if it's possible.
T.
More information about the Nitro-general
mailing list