module Locomotive::Steam::Liquid::Tags::Concerns::Attributes
Many of Liquid
tags have attributes (like options) This module makes sure we use the same reliable way to extract and evaluate them.
Attributes
attributes[R]
raw_attributes[R]
Private Instance Methods
evaluate_attributes(context, lax: false)
click to toggle source
# File lib/locomotive/steam/liquid/tags/concerns/attributes.rb, line 31 def evaluate_attributes(context, lax: false) @attributes = @raw_attributes.transform_values do |value| _value = context.evaluate(value) lax && _value.nil? ? value&.name : _value end end
parse_attributes(markup, default = {}) { |value| ... }
click to toggle source
# File lib/locomotive/steam/liquid/tags/concerns/attributes.rb, line 17 def parse_attributes(markup, default = {}) @attributes = default || {} @raw_attributes = @attributes.dup return if markup.blank? markup.scan(tag_attributes_regexp) do |key, value| _key = key.to_sym @attributes[_key] = block_given? ? yield(value) : ::Liquid::Expression.parse(value) @raw_attributes[_key] = @attributes[_key] end end
tag_attributes_regexp()
click to toggle source
# File lib/locomotive/steam/liquid/tags/concerns/attributes.rb, line 38 def tag_attributes_regexp ::Liquid::TagAttributes end