summaryrefslogtreecommitdiff
path: root/lib/tag.rb
blob: b0d5a8450353af47f2e159e83d22dac8f5f42ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module Virgil
  module Tag
    class Doctype
      def initialize(&block)
        @tag =  "<!DOCTYPE " +
                self.instance_eval(&block) +
                ">"
      end
      def to_s
        @tag
      end
    end
    class Comment
      def initialize(&block)
        @tag =  "<!--" +
                self.instance_eval(&block) +
                "-->"
      end
      def to_s
        @tag
      end
    end

    class Html < Utils::Generic
      def head(attrs = {})
        Head.new(attrs, &Proc.new).to_s
      end
      def body(attrs = {})
        Body.new(attrs, &Proc.new).to_s
      end

      class Body < Html
        def map(attrs = {})
          Map.new(attrs, &Proc.new).to_s
        end

        class Map < Utils::Generic
          def area(attrs = {})
            Area.new(attrs).to_s
          end

          class Area < Utils::GenericSingle ; end
        end
      end

      class Head < Html
        def link(attrs = {})
          Link.new(attrs).to_s
        end
        class Link < Utils::GenericSingle ; end

        def title(attrs = {})
          Title.new(attrs, &Proc.new).to_s
        end
        class Title < Utils::Generic ; end
      end
    end
  end
end