-
-
Save peczenyj/72892 to your computer and use it in GitHub Desktop.
HTML DSL, adicionando atributos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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