peczenyj (owner)

Fork Of

Revisions

gist: 72892 Download_button fork
public
Description:
HTML DSL, adicionando atributos
Public Clone URL: git://gist.github.com/72892.git
Embed All Files: show embed
dsl_for_html_generation.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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