class Haml::Parser::DynamicAttributes

@param [String] new - Hash literal including dynamic values. @param [String] old - Hash literal including dynamic values or Ruby literal of multiple Hashes which MUST be interpreted as method's last arguments.

Public Instance Methods

old=(value) click to toggle source
Calls superclass method
# File lib/haml/parser.rb, line 210
def old=(value)
  unless value =~ /\A{.*}\z/m
    raise ArgumentError.new('Old attributes must start with "{" and end with "}"')
  end
  super
end
to_literal() click to toggle source

This will be a literal for Haml::Buffer#attributes's last argument, `attributes_hashes`.

# File lib/haml/parser.rb, line 218
def to_literal
  [new, stripped_old].compact.join(', ')
end

Private Instance Methods

stripped_old() click to toggle source

For `%foo{ { foo: 1 }, bar: 2 }`, :old is “{ { foo: 1 }, bar: 2 }” and this method returns “ { foo: 1 }, bar: 2 ” for last argument.

# File lib/haml/parser.rb, line 225
def stripped_old
  return nil if old.nil?
  old.sub!(/\A{/, '').sub!(/}\z/m, '')
end