Using Gestalt in Views

48 views
Skip to first unread message

Rich

unread,
Jan 4, 2012, 7:11:54 AM1/4/12
to ram...@googlegroups.com
Can anyone advise on how to use Gestalt in Views, perhaps with a helpful example?  I have searched documentation, examples, specs  extensively but I am still in the dark.  I have managed to use Gestalt successfully only in a controller.

(not sure of group etiquette yet so TIA anyway.)


Yorick Peterse

unread,
Jan 4, 2012, 12:49:41 PM1/4/12
to ram...@googlegroups.com
Rich,

Gestalt can be used like any other class in your views (this example assumes
you're using Etanni):

<?r g = Ramaze::Gestalt.new ?>

<!-- Some HTML goes in here -->

<?r g.ul do ?>
<?r 10.times do ?>
<?r g.li do ?>
Some text goes in here, if all goes well this should be displayed
10 times.
<?r end ?>
<?r end ?>
<?r end ?>

Yorick

> --
> You received this message because you are subscribed to the Google Groups "Ramaze" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/ramaze/-/4uRCtYOzFE8J.
> To post to this group, send email to ram...@googlegroups.com.
> To unsubscribe from this group, send email to ramaze+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ramaze?hl=en.
>

Rich

unread,
Jan 5, 2012, 8:49:33 AM1/5/12
to ram...@googlegroups.com
Yorick

Thanks for rapid response.  Tried your example (plus the line 'helper :gestalt' in the controller) and the output was text only; no html tags were generated.  So I am part way there.

Rich

Yorick Peterse

unread,
Jan 5, 2012, 9:36:20 AM1/5/12
to ram...@googlegroups.com
Rich,

Woops, my bad. I was using the wrong tags and forgot to call
Ramaze::Gestalt#to_s. I wrote a small example which can be seen in this Gist:
https://gist.github.com/1565514. As you can see it's not very clean to directly
do it in the view but it is possible.

Yorick

> --
> You received this message because you are subscribed to the Google Groups "Ramaze" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/ramaze/-/r3NTAuO29nEJ.

Rich

unread,
Jan 6, 2012, 7:27:36 AM1/6/12
to ram...@googlegroups.com
Yorick

That works.
This aslo seems to work in a view file: 

<?r
html_page =
  build do
    html do
      head do
        title "Hello, World!"
      end
      body do
        h1 "Hello, World!", :style=>'color:green'
      end
    end
  end
?>

#{html_page}

and seems clean enough.

Not sure what module::ramaze::view::gestalt is for, maybe I should not worry about that. 

Thanks again
Rich

Yorick Peterse

unread,
Jan 6, 2012, 7:50:26 AM1/6/12
to ram...@googlegroups.com
Rich,

The view adapter Ramaze::View::Gestalt should make it possible for you to use
Gestalt in your views without having to mess around with those Etanni tags. I
haven't used it myself but the specifications show that you can use it as
following:

    html do
      head do
        title 'Page title goes in here'
      end
      body do
        h1 'This is the heading'
      end
    end


Yorick
--
You received this message because you are subscribed to the Google Groups "Ramaze" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ramaze/-/rhY0AWyK0kAJ.
signature.asc
Reply all
Reply to author
Forward
0 new messages