Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peczenyj/72892 to your computer and use it in GitHub Desktop.
Save peczenyj/72892 to your computer and use it in GitHub Desktop.
HTML DSL, adicionando atributos
def method_missing(name, *args)
attributes = args.last.to_a.collect {|y| y = "#{y[0]}=\"#{y[1]}\"" } .join(" ") if args.size > 1
puts "<#{name} #{attributes}>#{args.first}"
yield if block_given?
puts "</#{name}>"
end
html do
body do
h1 "My internal DSL"
br
a "some text" ,{ :href => "google.com" , :onClick => "javascript:alert(0);" }
div do
span "HTML generation engine in few lines"
ul do
li "take a look at Markaby"
li "at least once"
li "for some more ideas"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment