Class: Masstaden::HTM::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/masstaden/htm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject

Returns the value of attribute attributes.



9
10
11
# File 'lib/masstaden/htm.rb', line 9

def attributes
  @attributes
end

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/masstaden/htm.rb', line 9

def content
  @content
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/masstaden/htm.rb', line 9

def name
  @name
end

Instance Method Details

#renderObject



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