Class: Clot::LiquidForm
Constant Summary
collapse
- Syntax =
/([^\s]+)\s+/
Instance Method Summary
collapse
Methods included from TagHelper
#resolve_value, #split_params
#concat, #drop_class_to_table_item, #form_file_item, #form_input_item, #form_item, #form_select_item, #form_text_item, #get_attribute_value, #get_error_class, #get_id_from_name, #get_selection_value, #input_to_text, #set_param, #submit_button
#delete_link, #edit_link, #gen_delete_link, #gen_delete_onclick, #index_link, #new_link, #stylesheet_link, #view_link
Methods included from UrlFilters
#delete_link, #edit_link, #get_nested_edit_url, #get_nested_url, #index_link, #object_url, #stylesheet_url, #view_link
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ LiquidForm
Returns a new instance of LiquidForm.
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/clot/form_for.rb', line 15
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
#get_form_body(context) ⇒ Object
44
45
46
47
48
|
# File 'lib/clot/form_for.rb', line 44
def get_form_body(context)
context.stack do
render_all(@nodelist, context) * ""
end
end
|
50
51
52
|
# File 'lib/clot/form_for.rb', line 50
def
"</form>"
end
|
#render(context) ⇒ Object
28
29
30
31
|
# File 'lib/clot/form_for.rb', line 28
def render(context)
set_variables context
render_form context
end
|
33
34
35
36
37
38
|
# File 'lib/clot/form_for.rb', line 33
def render_form(context)
result = (context)
result += get_form_body(context)
result +=
result
end
|
#set_upload ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/clot/form_for.rb', line 54
def set_upload
if @attributes["uploading"] || @attributes["multipart"] == "true"
@upload_info = ' enctype="multipart/form-data"'
else
@upload_info = ''
end
end
|
#set_variables(context) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/clot/form_for.rb', line 62
def set_variables(context)
set_controller_action
set_form_action(context)
set_class
set_upload
end
|
#syntax_error ⇒ Object
40
41
42
|
# File 'lib/clot/form_for.rb', line 40
def syntax_error
raise SyntaxError.new("Syntax Error in form tag")
end
|