lib/view.rb in garterbelt-0.1.0 vs lib/view.rb in garterbelt-0.1.1

- old
+ new

@@ -140,10 +140,21 @@ else block_given? ? tag(*args, &block) : tag(*args) end end + def compact_tag(type, *args, &block) + args << {} unless args.last.is_a?(Hash) + args.last[:render_style] = :compact + + if block_given? + tag(type, *args, &block) + else + tag(type, *args) + end + end + def text(content) add_to_buffer Text.new(:view => _curator, :content => content) end alias :h :text @@ -184,10 +195,11 @@ opts[:attributes] = args.first else opts[:content] = args.first end end + opts[:render_style] = opts[:attributes].delete(:render_style) if opts[:attributes] && opts[:attributes][:render_style] opts end CONTENT_TAGS = [ 'a', 'abbr', 'acronym', 'address', @@ -201,11 +213,11 @@ 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'p', 'param', 'q', 's', 'samp', 'select', 'small', 'span', 'strong', 'sub', 'sup', - 'table', 'tbody', 'td', 'textarea', 'tfoot', + 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var' ] CONTENT_TAGS.each do |type| class_eval <<-RUBY def #{type}(*args, &block) @@ -235,9 +247,18 @@ HEAD_TAGS = ['base', 'meta', 'link'] HEAD_TAGS.each do |type| class_eval <<-RUBY def _#{type}(*args) closed_tag(:#{type}, *args) + end + RUBY + end + + MINIFIED_TAGS = ['textarea'] + MINIFIED_TAGS.each do |type| + class_eval <<-RUBY + def #{type}(*args, &block) + block_given? ? compact_tag(:#{type}, *args, &block) : compact_tag(:#{type}, *args) end RUBY end def page_title(*args, &block) \ No newline at end of file