class BetterHtml::Tree::Attribute
Attributes
equal_node[R]
name_node[R]
node[R]
value_node[R]
Public Class Methods
from_node(node)
click to toggle source
# File lib/better_html/tree/attribute.rb, line 13 def self.from_node(node) new(node) end
new(node)
click to toggle source
# File lib/better_html/tree/attribute.rb, line 8 def initialize(node) @node = node @name_node, @equal_node, @value_node = *node if @node.type == :attribute end
Public Instance Methods
erb?()
click to toggle source
# File lib/better_html/tree/attribute.rb, line 17 def erb? @node.type == :erb end
loc()
click to toggle source
# File lib/better_html/tree/attribute.rb, line 21 def loc @node.loc end
name()
click to toggle source
# File lib/better_html/tree/attribute.rb, line 25 def name @name_node&.loc&.source&.downcase end
value()
click to toggle source
# File lib/better_html/tree/attribute.rb, line 29 def value parts = value_node.to_a.reject{ |node| node.is_a?(::AST::Node) && node.type == :quote } parts.map { |s| s.is_a?(::AST::Node) ? s.loc.source : CGI.unescapeHTML(s) }.join end