Module: Tagz::Buffer

Defined in:
lib/tagz/buffer.rb

Overview

Buffer

When included, Tagz::Buffer allows a tag’s block to have several calls to #tag, which are collected and assigned as the parent tag’s contents.

Examples

tag :div do
  tag :label, 'Comments:', :for => :comments
  tag :textarea, :id => :comments
end

<div>
  <label for="comments">Comments:</label>
  <textarea id="comments"></textarea>
</div>

Defined Under Namespace

Classes: Base

Instance Method Summary collapse

Instance Method Details

#create_tag(name, contents, attrs, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/tagz/buffer.rb', line 40

def create_tag name, contents, attrs, &block
  if block
    buffer = Base.new
    buffer.instance_eval &block
    super name, "#{contents}#{buffer}", attrs
  else
    super
  end
end