Class: Masstaden::HTM::Tag
- Inherits:
-
Object
- Object
- Masstaden::HTM::Tag
- Defined in:
- lib/masstaden/htm.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#content ⇒ Object
Returns the value of attribute content.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Tag
constructor
A new instance of Tag.
- #render ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Tag
Returns a new instance of Tag.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/masstaden/htm.rb', line 11 def initialize(*args, &block) @name = args.shift @attributes = {} @content = nil @block = block args.each do |arg| if arg.is_a?(Hash) @attributes = arg elsif arg.is_a?(String) @content = arg end end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/masstaden/htm.rb', line 9 def attributes @attributes end |
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/masstaden/htm.rb', line 9 def content @content end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/masstaden/htm.rb', line 9 def name @name end |
Instance Method Details
#render ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/masstaden/htm.rb', line 26 def render if @block r_open + @block.call + r_close elsif @content.is_a?(String) r_open + @content + r_close else r_open + r_close end end |