Ruby/Network/HTML Builder
Материал из Wiki.crossplatform.ru
integrate Ruby logic and flow control into the HTML generation process
require "rubygems" require "markaby" m = Markaby::Builder.new items = ["Bread", "Butter", "Tea", "Coffee"] m.html do body do h1 "My Shopping List" ol do items.each do |item| li item end end end end puts m
Markaby-Markup As Ruby
# gem install markaby require "rubygems" require "markaby" m = Markaby::Builder.new m.html do head { title "This is the title" } body do h1 "Hello world" h2 "Sub-heading" p %q{This is a test} h2 "Another sub-heading" p "test:" ul do li "Generating HTML from Ruby" li "Keeping HTML structured" li "Lots more.." end end end puts m