Class: Hamlit::Attribute
- Inherits:
-
Object
- Object
- Hamlit::Attribute
- Includes:
- Concerns::AttributeBuilder
- Defined in:
- lib/hamlit/attribute.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build(base, attributes) ⇒ Object
-
#initialize(quote) ⇒ Attribute
constructor
A new instance of Attribute.
Methods included from Concerns::AttributeBuilder
Constructor Details
#initialize(quote) ⇒ Attribute
Returns a new instance of Attribute.
18 19 20 |
# File 'lib/hamlit/attribute.rb', line 18 def initialize(quote) @quote = quote end |
Class Method Details
.build(quote, base, attributes = {}) ⇒ Object
13 14 15 16 |
# File 'lib/hamlit/attribute.rb', line 13 def self.build(quote, base, attributes = {}) builder = self.new(quote) builder.build(base, attributes) end |
Instance Method Details
#build(base, attributes) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hamlit/attribute.rb', line 22 def build(base, attributes) result = '' merge_attributes(base, attributes).each do |key, value| if value == true result += " #{key}" next end escaped = Temple::Utils.escape_html(value) result += " #{key}=#{@quote}#{escaped}#{@quote}" end result end |