Class: Clot::ClotTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
AttributeSetter, TagHelper
Defined in:
lib/clot/no_model_form_tags.rb

Constant Summary collapse

Syntax =
/([^\s]+)\s+/

Instance Method Summary collapse

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#personal_attributes, #set_attributes, #set_primary_attributes

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ ClotTag

Returns a new instance of ClotTag.



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/clot/no_model_form_tags.rb', line 54

def initialize(tag_name, markup, tokens)
  if markup =~ Syntax
    @form_object = $1
    @attributes = {}
    markup.scan(Liquid::TagAttributes) do |key, value|
      @attributes[key] = value
    end
  else
    syntax_error tag_name, markup, tokens
  end
  super
end

Instance Method Details

#render(context) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/clot/no_model_form_tags.rb', line 67

def render(context)
  @attributes.each do |key, value|
    @attributes[key] = resolve_value(value, context)
  end

  @form_object = context[@form_object].to_sym if context[@form_object].is_a?(String)
  @form_object = context[@form_object].source if @form_object.nil? && context[@form_object].is_a?(Liquid::Drop)
end