Class: Plate::LinkNode

Inherits:
AttributableNode show all
Defined in:
lib/plate/nodes.rb,
lib/plate/compiler.rb

Instance Attribute Summary collapse

Attributes inherited from AttributableNode

#attributes

Instance Method Summary collapse

Methods inherited from AttributableNode

#compile_attributes

Methods included from Inspector

#inspect_with

Constructor Details

#initialize(text, href, attributes) ⇒ LinkNode

Returns a new instance of LinkNode.



85
86
87
88
89
# File 'lib/plate/nodes.rb', line 85

def initialize(text, href, attributes)
  self.text = text
  self.href = href
  self.attributes = attributes
end

Instance Attribute Details

#hrefObject

Returns the value of attribute href.



84
85
86
# File 'lib/plate/nodes.rb', line 84

def href
  @href
end

#textObject

Returns the value of attribute text.



84
85
86
# File 'lib/plate/nodes.rb', line 84

def text
  @text
end

Instance Method Details

#compile(compiler, parent = nil) ⇒ Object



240
241
242
243
244
# File 'lib/plate/compiler.rb', line 240

def compile(compiler, parent = nil)
  content = text.compile(compiler)
  attr = compile_attributes(compiler)
  "<a href=\"#{href.compile(compiler)}\"#{attr}>#{content}</a>"
end

#inspectObject



91
92
93
# File 'lib/plate/nodes.rb', line 91

def inspect
  inspect_with([text, href])
end