forked from manveru/ramaze
-
Notifications
You must be signed in to change notification settings - Fork 37
Writing HTML programmatically
Michel Blanc edited this page Aug 11, 2012
·
1 revision
{Ramaze::Gestalt} is a utility class that can help you writing html programatically, so you don't have to "stuff" a String with HTML, or use here documents.
Here is the above code, revisited with Ramaze:Gestalt
def generate(current=nil)
# Generate some HTML that will make create the side bar
sidebar = Ramaze::Gestalt.new
sidebar.div(:class =>"sd") do
sidebar.h1 "This is a sidebar"
sidebar.ul do
sidebar.li "First item"
sidebar.li "Second item"
end
end
sidebar.to_s
end
You can also use the Gestalt builder, which is a bit less verbose :
def generate(current=nil)
# Generate some HTML that will make the side bar
sidebar = Ramaze::Gestalt.build do
div(:class =>"sd") do
h1 "This is a sidebar"
ul do
li "First item"
li "Second item"
end
end
end
end
- Website
- Google Groups
- User Guide
- [#ramaze on the Freenode network] (http://webchat.freenode.net/?channels=ramaze)