Module: Cms::TagCommon

Extended by:
ActiveSupport::Memoizable
Included in:
DataTag::TagMethods
Defined in:
app/liquid/tags/cms/tag_common.rb

Constant Summary collapse

HyphenatedTagAttributes =
/([\w-]+)\s*\:\s*(#{Liquid::QuotedFragment})/

Instance Method Summary collapse

Instance Method Details

#context_object(context) ⇒ Object



21
22
23
# File 'app/liquid/tags/cms/tag_common.rb', line 21

def context_object(context)
  context.registers[:context].object
end

#params(context) ⇒ Object



26
27
28
# File 'app/liquid/tags/cms/tag_common.rb', line 26

def params(context)
  context.registers[:controller].params.except(:controller, :action)
end

#parse_options(context, markup) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/liquid/tags/cms/tag_common.rb', line 6

def parse_options(context, markup)
  begin
    options = HashWithIndifferentAccess.new
    return options if markup.blank?

    markup.scan(HyphenatedTagAttributes) do |key, value|
      options[key.to_sym] = context[value]
    end

    options
  rescue ArgumentError => e
    raise SyntaxError.new("Syntax Error in 'tag options' - Valid syntax: name:value")
  end
end