Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....
code in pure Ruby. It is an alternative to templating languages such as ERb
ERuby
eRuby is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP, JSP and PHP.-Usage:eRuby allows Ruby code to be embedded within a pair of delimiters...
Haml is a lightweight markup language that is used to describe the XHTML of any web document without the use of traditional inline coding. It’s designed to address many of the flaws in traditional templating engines, as well as making markup as elegant as it can be...
which combine Ruby code with some form of markup. It was developed by anonymous computer programmer "why the lucky stiff
Why the lucky stiff
why the lucky stiff is the persona formerly used by an anonymous and prolific writer, cartoonist, musician, artist, and computer programmer notable for his work with the Ruby programming language...
" and its name comes from Markup as Ruby.
Usage
require 'markaby'
mab = Markaby::Builder.new
mab.html do
head { title "Boats.com" }
body do
h1 "Boats.com has great deals"
ul do
li "$49 for a canoe"
li "$39 for a raft"
li "$29 for a huge boot that floats and can fit 5 people"
end
end
end
puts mab.to_s
Executing the above code will render the following HTML:
Boats.com
Boats.com has great deals
$49 for a canoe
$39 for a raft
$29 for a huge boot that floats and can fit 5 people
Camping is a web application framework written in Ruby which consistently stays under 4kb - the complete source code can be viewed on a single page....
.
module HomePage::Views
# If you have a `layout' method like this, it
# will wrap the HTML in the other methods. The
# `self << yield' is where the HTML is inserted.
def layout
html do
title { 'My HomePage' }
body { self << yield }
end
end
# The `index' view. Inside your views, you express
# the HTML in Ruby. See http://code.whytheluckystiff.net/markaby/.
def index
p 'Hi my name is Charles.'
p 'Here are some links:'
ul do
li { a 'Google', :href => 'http://google.com/' }
li { a 'A sample page', :href => '/sample' }
end
end
# The `sample' view.
def sample
p 'A sample page'
end
end