Class: Plate::HeaderNode

Inherits:
RichNode
  • Object
show all
Defined in:
lib/plate/nodes.rb,
lib/plate/compiler.rb

Instance Attribute Summary collapse

Attributes inherited from RichNode

#body, #parent, #scripts, #styles

Instance Method Summary collapse

Methods inherited from RichNode

#compile_body, #parent_repeat?, #repeat?

Methods included from Inspector

#inspect_with

Constructor Details

#initialize(level, text, body) ⇒ HeaderNode

Returns a new instance of HeaderNode.



44
45
46
47
48
# File 'lib/plate/nodes.rb', line 44

def initialize(level, text, body)
  super(body)
  self.level = level
  self.text = text
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



43
44
45
# File 'lib/plate/nodes.rb', line 43

def level
  @level
end

#textObject

Returns the value of attribute text.



43
44
45
# File 'lib/plate/nodes.rb', line 43

def text
  @text
end

Instance Method Details

#compile(compiler, parent = nil) ⇒ Object



224
225
226
227
228
# File 'lib/plate/compiler.rb', line 224

def compile(compiler, parent = nil)
  tag = "h#{level}"
  style, script = compile_body(compiler, parent)
  "<#{tag}#{style}#{script}>#{text.compile(compiler, self)}</#{tag}>"
end

#inspectObject



50
51
52
# File 'lib/plate/nodes.rb', line 50

def inspect
  inspect_with([level, text])
end