padrino-helpers 0.11.4 → 0.12.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +6 -6
- data/lib/padrino-helpers/asset_tag_helpers.rb +26 -33
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +16 -17
- data/lib/padrino-helpers/form_helpers.rb +121 -129
- data/lib/padrino-helpers/format_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +25 -60
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +7 -58
- data/lib/padrino-helpers/output_helpers/haml_handler.rb +5 -43
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +5 -65
- data/lib/padrino-helpers/output_helpers.rb +26 -13
- data/lib/padrino-helpers/render_helpers.rb +21 -18
- data/lib/padrino-helpers.rb +1 -0
- data/padrino-helpers.gemspec +2 -1
- data/test/fixtures/markup_app/app.rb +14 -10
- data/test/fixtures/markup_app/views/button_to.haml +2 -2
- data/test/fixtures/markup_app/views/capture_concat.haml +3 -3
- data/test/fixtures/markup_app/views/capture_concat.slim +3 -3
- data/test/fixtures/markup_app/views/content_for.erb +10 -1
- data/test/fixtures/markup_app/views/content_for.haml +7 -0
- data/test/fixtures/markup_app/views/content_for.slim +8 -1
- data/test/fixtures/markup_app/views/content_tag.erb +2 -0
- data/test/fixtures/markup_app/views/content_tag.haml +4 -2
- data/test/fixtures/markup_app/views/content_tag.slim +3 -1
- data/test/fixtures/markup_app/views/fields_for.haml +4 -4
- data/test/fixtures/markup_app/views/form_for.haml +3 -3
- data/test/fixtures/markup_app/views/form_tag.haml +6 -6
- data/test/fixtures/markup_app/views/link_to.haml +1 -1
- data/test/fixtures/markup_app/views/simple_partial.slim +1 -1
- data/test/fixtures/render_app/app.rb +16 -4
- data/test/fixtures/render_app/views/_deep.erb +3 -0
- data/test/fixtures/render_app/views/_deep.haml +2 -0
- data/test/fixtures/render_app/views/_deep.slim +2 -0
- data/test/fixtures/render_app/views/_partial_block_erb.erb +10 -0
- data/test/fixtures/render_app/views/_partial_block_haml.haml +7 -0
- data/test/fixtures/render_app/views/_partial_block_slim.slim +7 -0
- data/test/fixtures/render_app/views/double_capture_erb.erb +2 -2
- data/test/fixtures/render_app/views/double_capture_haml.haml +1 -1
- data/test/fixtures/render_app/views/double_capture_slim.slim +1 -1
- data/test/fixtures/render_app/views/render_block_erb.erb +5 -0
- data/test/fixtures/render_app/views/render_block_haml.haml +4 -0
- data/test/fixtures/render_app/views/render_block_slim.slim +4 -0
- data/test/fixtures/render_app/views/wrong_capture_erb.erb +3 -0
- data/test/fixtures/render_app/views/wrong_capture_haml.haml +2 -0
- data/test/fixtures/render_app/views/wrong_capture_slim.slim +2 -0
- data/test/test_asset_tag_helpers.rb +34 -0
- data/test/test_form_builder.rb +10 -0
- data/test/test_form_helpers.rb +18 -18
- data/test/test_format_helpers.rb +10 -0
- data/test/test_output_helpers.rb +25 -22
- data/test/test_render_helpers.rb +67 -0
- data/test/test_tag_helpers.rb +9 -0
- metadata +38 -7
@@ -2,62 +2,24 @@ module Padrino
|
|
2
2
|
module Helpers
|
3
3
|
module OutputHelpers
|
4
4
|
##
|
5
|
-
# Handler for
|
5
|
+
# Handler for Haml templates.
|
6
6
|
#
|
7
7
|
class HamlHandler < AbstractHandler
|
8
8
|
##
|
9
|
-
# Returns true if the
|
9
|
+
# Returns true if the block is for Haml
|
10
10
|
#
|
11
|
-
|
12
|
-
# @handler.is_type? => true
|
13
|
-
#
|
14
|
-
def is_type?
|
15
|
-
template.respond_to?(:is_haml?) && template.is_haml?
|
16
|
-
end
|
17
|
-
|
18
|
-
##
|
19
|
-
# Returns true if the block given is of the handler's template type; false otherwise.
|
20
|
-
#
|
21
|
-
# @example
|
22
|
-
# @handler.block_is_type?(block) => true
|
23
|
-
#
|
24
|
-
def block_is_type?(block)
|
11
|
+
def engine_matches?(block)
|
25
12
|
template.block_is_haml?(block)
|
26
13
|
end
|
27
14
|
|
28
15
|
##
|
29
16
|
# Captures the html from a block of template code for this handler.
|
30
17
|
#
|
31
|
-
# @example
|
32
|
-
# @handler.capture_from_template(&block) => "...html..."
|
33
|
-
#
|
34
18
|
def capture_from_template(*args, &block)
|
35
|
-
|
36
|
-
template.capture_haml(*args, &block)
|
37
|
-
end
|
38
|
-
|
39
|
-
##
|
40
|
-
# Outputs the given text to the templates buffer directly.
|
41
|
-
#
|
42
|
-
# @example
|
43
|
-
# @handler.concat_to_template("This will be output to the template buffer")
|
44
|
-
#
|
45
|
-
def concat_to_template(text="")
|
46
|
-
template.haml_concat(text)
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
|
50
|
-
##
|
51
|
-
# Returns an array of engines used for the template.
|
52
|
-
#
|
53
|
-
# @example
|
54
|
-
# @handler.engines => [:haml]
|
55
|
-
#
|
56
|
-
def engines
|
57
|
-
@_engines ||= [:haml]
|
19
|
+
engine_matches?(block) ? template.capture_haml(*args, &block) : block.call(*args)
|
58
20
|
end
|
59
21
|
end
|
60
|
-
OutputHelpers.register(HamlHandler)
|
22
|
+
OutputHelpers.register(:haml, HamlHandler)
|
61
23
|
end
|
62
24
|
end
|
63
25
|
end
|
@@ -2,77 +2,17 @@ module Padrino
|
|
2
2
|
module Helpers
|
3
3
|
module OutputHelpers
|
4
4
|
##
|
5
|
-
# Handler for
|
5
|
+
# Handler for Slim templates.
|
6
6
|
#
|
7
7
|
class SlimHandler < AbstractHandler
|
8
|
-
attr_reader :output_buffer
|
9
|
-
|
10
|
-
def initialize(template)
|
11
|
-
super
|
12
|
-
@output_buffer = template.instance_variable_get(:@_out_buf)
|
13
|
-
end
|
14
|
-
|
15
|
-
##
|
16
|
-
# Returns true if the current template type is same as this handlers; false otherwise.
|
17
|
-
#
|
18
|
-
# @example
|
19
|
-
# @handler.is_type? => true
|
20
|
-
#
|
21
|
-
def is_type?
|
22
|
-
!self.output_buffer.nil?
|
23
|
-
end
|
24
|
-
|
25
8
|
##
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# @handler.capture_from_template(&block) => "...html..."
|
30
|
-
#
|
31
|
-
def capture_from_template(*args, &block)
|
32
|
-
self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer
|
33
|
-
captured_block = block.call(*args)
|
34
|
-
ret = eval("@_out_buf", block.binding)
|
35
|
-
self.output_buffer = _buf_was
|
36
|
-
[ ret, captured_block ]
|
37
|
-
end
|
38
|
-
|
39
|
-
##
|
40
|
-
# Outputs the given text to the templates buffer directly.
|
41
|
-
#
|
42
|
-
# @example
|
43
|
-
# @handler.concat_to_template("This will be output to the template buffer")
|
9
|
+
# Returns true if the block is for Slim.
|
44
10
|
#
|
45
|
-
def
|
46
|
-
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
|
50
|
-
##
|
51
|
-
# Returns true if the block given is of the handler's template type; false otherwise.
|
52
|
-
#
|
53
|
-
# @example
|
54
|
-
# @handler.block_is_type?(block) => true
|
55
|
-
#
|
56
|
-
def block_is_type?(block)
|
57
|
-
is_type? || (block && eval('defined? __in_erb_template', block.binding))
|
58
|
-
end
|
59
|
-
|
60
|
-
##
|
61
|
-
# Returns an array of engines used for the template.
|
62
|
-
#
|
63
|
-
# @example
|
64
|
-
# @handler.engines => [:erb, :erubis]
|
65
|
-
#
|
66
|
-
def engines
|
67
|
-
@_engines ||= [:slim]
|
68
|
-
end
|
69
|
-
|
70
|
-
protected
|
71
|
-
def output_buffer=(val)
|
72
|
-
template.instance_variable_set(:@_out_buf, val)
|
11
|
+
def engine_matches?(block)
|
12
|
+
block.binding.eval('defined? __in_slim_template')
|
73
13
|
end
|
74
14
|
end
|
75
|
-
OutputHelpers.register(SlimHandler)
|
15
|
+
OutputHelpers.register(:slim, SlimHandler)
|
76
16
|
end
|
77
17
|
end
|
78
18
|
end
|
@@ -8,6 +8,20 @@ module Padrino
|
|
8
8
|
base.send(:include, SinatraCurrentEngine) unless base.method_defined?(:current_engine)
|
9
9
|
end
|
10
10
|
|
11
|
+
##
|
12
|
+
# Returns the list of all available template handlers.
|
13
|
+
#
|
14
|
+
def self.handlers
|
15
|
+
@_template_handlers ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Registers a new handler as available to the output helpers.
|
20
|
+
#
|
21
|
+
def self.register(engine, handler)
|
22
|
+
handlers[engine] = handler
|
23
|
+
end
|
24
|
+
|
11
25
|
##
|
12
26
|
# Module used to detect the current engine in vanilla Sinatra apps.
|
13
27
|
#
|
@@ -45,14 +59,11 @@ module Padrino
|
|
45
59
|
# # => "<foo>"
|
46
60
|
#
|
47
61
|
def capture_html(*args, &block)
|
48
|
-
handler = find_proper_handler
|
49
|
-
|
50
|
-
|
51
|
-
|
62
|
+
if handler = find_proper_handler
|
63
|
+
handler.capture_from_template(*args, &block)
|
64
|
+
else
|
65
|
+
block.call(*args)
|
52
66
|
end
|
53
|
-
# invoking the block directly if there was no template
|
54
|
-
captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank?
|
55
|
-
captured_html
|
56
67
|
end
|
57
68
|
alias :capture :capture_html
|
58
69
|
|
@@ -68,10 +79,9 @@ module Padrino
|
|
68
79
|
# concat_content("This will be output to the template buffer")
|
69
80
|
#
|
70
81
|
def concat_content(text="")
|
71
|
-
handler = find_proper_handler
|
72
|
-
if handler && handler.is_type?
|
82
|
+
if handler = find_proper_handler
|
73
83
|
handler.concat_to_template(text)
|
74
|
-
else
|
84
|
+
else
|
75
85
|
text
|
76
86
|
end
|
77
87
|
end
|
@@ -105,7 +115,7 @@ module Padrino
|
|
105
115
|
#
|
106
116
|
def block_is_template?(block)
|
107
117
|
handler = find_proper_handler
|
108
|
-
block && handler && handler.
|
118
|
+
block && handler && handler.engine_matches?(block)
|
109
119
|
end
|
110
120
|
|
111
121
|
##
|
@@ -124,7 +134,9 @@ module Padrino
|
|
124
134
|
# content_for(:name) { |name| ...content... }
|
125
135
|
# content_for(:name, "I'm Jeff")
|
126
136
|
#
|
127
|
-
def content_for(key, content = nil, &block)
|
137
|
+
def content_for(key, content = nil, options = {}, &block)
|
138
|
+
options = content if content.is_a?(Hash)
|
139
|
+
content_blocks[key.to_sym].clear if options[:flush]
|
128
140
|
content_blocks[key.to_sym] << (block_given? ? block : Proc.new { content })
|
129
141
|
end
|
130
142
|
|
@@ -185,7 +197,8 @@ module Padrino
|
|
185
197
|
# find_proper_handler => <OutputHelpers::HamlHandler>
|
186
198
|
#
|
187
199
|
def find_proper_handler
|
188
|
-
OutputHelpers.handlers
|
200
|
+
handler_class = OutputHelpers.handlers[current_engine]
|
201
|
+
handler_class && handler_class.new(self)
|
189
202
|
end
|
190
203
|
|
191
204
|
##
|
@@ -30,27 +30,30 @@ module Padrino
|
|
30
30
|
#
|
31
31
|
# @note If using this from Sinatra, pass explicit +:engine+ option
|
32
32
|
#
|
33
|
-
def partial(template, options={})
|
34
|
-
options.reverse_merge
|
35
|
-
path = template.to_s.split(File::SEPARATOR)
|
36
|
-
object_name = path[-1].to_sym
|
37
|
-
path[-1] = "_#{path[-1]}"
|
33
|
+
def partial(template, options={}, &block)
|
34
|
+
options = options.reverse_merge(:locals => {}, :layout => false)
|
38
35
|
explicit_engine = options.delete(:engine)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
options[:locals].merge!(object_name => member, "#{object_name}_counter".to_sym => counter)
|
47
|
-
render(explicit_engine, template_path, options.dup)
|
48
|
-
}.join("\n").html_safe
|
36
|
+
|
37
|
+
path,_,name = template.to_s.rpartition(File::SEPARATOR)
|
38
|
+
template_path = File.join(path,"_#{name}").to_sym
|
39
|
+
object_name = name.to_sym
|
40
|
+
|
41
|
+
objects, counter = if options[:collection].respond_to?(:inject)
|
42
|
+
[options.delete(:collection), 0]
|
49
43
|
else
|
50
|
-
|
51
|
-
|
44
|
+
[[options.delete(:object)], nil]
|
45
|
+
end
|
46
|
+
|
47
|
+
locals = options[:locals]
|
48
|
+
objects.inject(''.html_safe) do |html,object|
|
49
|
+
locals[object_name] = object if object
|
50
|
+
locals["#{object_name}_counter".to_sym] = counter += 1 if counter
|
51
|
+
if block_given?
|
52
|
+
output = render(explicit_engine, template_path, options){ capture_html(&block) }.html_safe
|
53
|
+
html << (block_is_template?(block) ? concat_content(output) : output)
|
54
|
+
else
|
55
|
+
html << render(explicit_engine, template_path, options).html_safe
|
52
56
|
end
|
53
|
-
render(explicit_engine, template_path, options.dup).html_safe
|
54
57
|
end
|
55
58
|
end
|
56
59
|
alias :render_partial :partial
|
data/lib/padrino-helpers.rb
CHANGED
data/padrino-helpers.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
s.version = Padrino.version
|
16
16
|
s.date = Time.now.strftime("%Y-%m-%d")
|
17
|
+
s.license = "MIT"
|
17
18
|
|
18
19
|
s.extra_rdoc_files = Dir["*.rdoc"]
|
19
20
|
s.files = `git ls-files`.split("\n")
|
@@ -23,5 +24,5 @@ Gem::Specification.new do |s|
|
|
23
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
24
25
|
|
25
26
|
s.add_dependency("padrino-core", Padrino.version)
|
26
|
-
s.add_dependency("i18n", "~> 0.6")
|
27
|
+
s.add_dependency("i18n", "~> 0.6", ">= 0.6.7")
|
27
28
|
end
|
@@ -1,22 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
require 'haml'
|
3
|
-
require 'erubis'
|
4
|
-
require 'slim'
|
5
|
-
require 'padrino-core/application/rendering/extensions/erubis'
|
6
|
-
require 'padrino-core/application/rendering/extensions/haml'
|
7
|
-
require 'padrino-core/application/rendering/extensions/slim'
|
1
|
+
require 'padrino-core'
|
8
2
|
|
9
3
|
class MarkupDemo < Sinatra::Base
|
10
4
|
register Padrino::Helpers
|
5
|
+
register Padrino::Rendering
|
11
6
|
|
12
7
|
configure do
|
13
8
|
set :logging, false
|
14
9
|
set :padrino_logging, false
|
15
10
|
set :environment, :test
|
16
11
|
set :root, File.dirname(__FILE__)
|
17
|
-
set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
|
18
|
-
set :haml, :escape_html => true
|
19
|
-
set :slim, :generator => Temple::Generators::RailsOutputBuffer, :buffer => "out_buf"
|
20
12
|
set :sessions, true
|
21
13
|
set :protect_from_csrf, true
|
22
14
|
end
|
@@ -50,6 +42,18 @@ class MarkupDemo < Sinatra::Base
|
|
50
42
|
content_tag(:span, "This not a template block")
|
51
43
|
end
|
52
44
|
end
|
45
|
+
|
46
|
+
def content_tag_with_block
|
47
|
+
one = content_tag(:p) do
|
48
|
+
"one"
|
49
|
+
end
|
50
|
+
two = content_tag(:p) do
|
51
|
+
"two"
|
52
|
+
end
|
53
|
+
one << two
|
54
|
+
rescue
|
55
|
+
"<p>failed</p>".html_safe
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
= button_to 'Foo button', '/foo', :class => 'foo-form' do
|
2
|
+
= field_set_tag do
|
3
3
|
= label_tag :username
|
4
4
|
= content_tag(:p, 'button_to test', :id => 'test-point')
|
5
5
|
= button_to 'Bar button', '/bar'
|
@@ -3,10 +3,10 @@
|
|
3
3
|
%span Captured Line 2
|
4
4
|
= @content
|
5
5
|
|
6
|
-
|
6
|
+
= concat_in_p('Concat Line 3')
|
7
7
|
|
8
|
-
|
8
|
+
= concat_if_block_is_template('haml') do
|
9
9
|
%span This is haml
|
10
10
|
%span This is haml
|
11
11
|
|
12
|
-
|
12
|
+
= concat_ruby_not_template_block
|
@@ -3,10 +3,10 @@
|
|
3
3
|
span Captured Line 2
|
4
4
|
= @content
|
5
5
|
|
6
|
-
|
6
|
+
= concat_in_p('Concat Line 3')
|
7
7
|
|
8
|
-
|
8
|
+
= concat_if_block_is_template('slim') do
|
9
9
|
span This is slim
|
10
10
|
span This is slim
|
11
11
|
|
12
|
-
|
12
|
+
= concat_ruby_not_template_block
|
@@ -11,4 +11,13 @@
|
|
11
11
|
<div class='demo2'><%= yield_content :demo2, "Johnny", "Smith" %></div>
|
12
12
|
|
13
13
|
<div class="demo_has_content"><%= content_for?(:demo).to_s %>
|
14
|
-
<div class="fake_has_content"><%= content_for?(:fake).to_s %>
|
14
|
+
<div class="fake_has_content"><%= content_for?(:fake).to_s %>
|
15
|
+
|
16
|
+
<% content_for :demo3 do %>
|
17
|
+
<p class="duplication">One</p>
|
18
|
+
<% end %>
|
19
|
+
<% content_for :demo3, :flush => true do %>
|
20
|
+
<p class="duplication">Two</p>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<div class="demo3"><%= yield_content :demo3 %></div>
|
@@ -10,3 +10,10 @@
|
|
10
10
|
|
11
11
|
.demo_has_content= content_for?(:demo)
|
12
12
|
.fake_has_content= content_for?(:fake)
|
13
|
+
|
14
|
+
- content_for :demo3 do
|
15
|
+
%p{:class => "duplication"} One
|
16
|
+
- content_for :demo3, :flush => true do
|
17
|
+
%p{:class => "duplication"} Two
|
18
|
+
|
19
|
+
.demo3= yield_content :demo3
|
@@ -9,4 +9,11 @@
|
|
9
9
|
.demo2= yield_content :demo2, "Johnny", "Smith"
|
10
10
|
|
11
11
|
.demo_has_content= content_for?(:demo)
|
12
|
-
.fake_has_content= content_for?(:fake)
|
12
|
+
.fake_has_content= content_for?(:fake)
|
13
|
+
|
14
|
+
- content_for :demo3 do
|
15
|
+
p.duplication One
|
16
|
+
- content_for :demo3, :flush => true do
|
17
|
+
p.duplication Two
|
18
|
+
|
19
|
+
.demo3= yield_content :demo3
|
@@ -1,13 +1,13 @@
|
|
1
1
|
- @user = MarkupUser.new
|
2
|
-
|
2
|
+
= form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
|
3
3
|
= f.text_field :gender
|
4
|
-
|
4
|
+
= fields_for @user.permission do |permission|
|
5
5
|
= permission.check_box :can_edit
|
6
6
|
= permission.check_box :can_delete
|
7
|
-
|
7
|
+
= f.fields_for :telephone do |child_form|
|
8
8
|
= child_form.label :number
|
9
9
|
= child_form.text_field :number
|
10
|
-
|
10
|
+
= f.fields_for :addresses do |child_form|
|
11
11
|
= child_form.label :name
|
12
12
|
= child_form.text_field :name
|
13
13
|
- unless child_form.object.new_record?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
= form_for MarkupUser.new, '/demo', :id => 'demo' do |f|
|
2
2
|
= f.error_messages(:header_message => "custom MarkupUser cannot be saved!")
|
3
3
|
= f.hidden_field :session_id
|
4
4
|
%p
|
@@ -43,7 +43,7 @@
|
|
43
43
|
%p
|
44
44
|
= f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button'
|
45
45
|
|
46
|
-
|
46
|
+
= form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f|
|
47
47
|
= f.error_messages :header_message => "custom MarkupUser cannot be saved!"
|
48
48
|
= f.hidden_field :session_id
|
49
49
|
= f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' }
|
@@ -55,5 +55,5 @@
|
|
55
55
|
= f.submit_block "Create", { :class => 'button' }
|
56
56
|
= f.image_submit_block "buttons/ok.png", { :class => 'image' }
|
57
57
|
|
58
|
-
|
58
|
+
= form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f|
|
59
59
|
= f.text_field_block :username
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
= form_tag '/simple', :class => 'simple-form' do
|
2
2
|
= error_messages_for nil
|
3
|
-
|
3
|
+
= field_set_tag do
|
4
4
|
= hidden_field_tag :session_id, :value => "__secret__"
|
5
5
|
= label_tag :username
|
6
6
|
= text_field_tag :username
|
@@ -26,10 +26,10 @@
|
|
26
26
|
= check_box_tag :remember_me
|
27
27
|
= submit_tag
|
28
28
|
|
29
|
-
|
29
|
+
= form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do
|
30
30
|
= error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!"
|
31
31
|
= hidden_field_tag :session_id, :value => "__secret__"
|
32
|
-
|
32
|
+
= field_set_tag "Advanced", :class => 'advanced-field-set' do
|
33
33
|
%p
|
34
34
|
= label_tag :username, :class => 'first', :caption => "Nickname"
|
35
35
|
= text_field_tag :username, :value => params[:username], :id => 'the_username'
|
@@ -69,10 +69,10 @@
|
|
69
69
|
%p
|
70
70
|
= range_field_tag('ranger_with_min_max', :min => 1, :max => 50)
|
71
71
|
= range_field_tag('ranger_with_range', :range => 1..5)
|
72
|
-
|
72
|
+
= field_set_tag(:class => 'buttons') do
|
73
73
|
= submit_tag "Login"
|
74
74
|
= button_tag "Cancel"
|
75
75
|
= image_submit_tag "buttons/submit.png"
|
76
76
|
|
77
|
-
|
77
|
+
= form_tag '/dontprotect', :class => 'no-protection', :protect_from_csrf => false do
|
78
78
|
= submit_tag "Login"
|
@@ -1 +1 @@
|
|
1
|
-
p.slim= partial 'partials/slim', :engine => "slim"
|
1
|
+
p.slim= partial 'partials/slim', :engine => "slim"
|
@@ -2,7 +2,6 @@ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
|
2
2
|
PADRINO_ENV = 'test' unless defined? PADRINO_ENV
|
3
3
|
|
4
4
|
require 'padrino-core'
|
5
|
-
require 'slim'
|
6
5
|
|
7
6
|
class RenderUser
|
8
7
|
attr_accessor :name
|
@@ -17,9 +16,6 @@ class RenderDemo < Padrino::Application
|
|
17
16
|
set :logging, false
|
18
17
|
set :padrino_logging, false
|
19
18
|
set :environment, :test
|
20
|
-
set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
|
21
|
-
set :haml, :escape_html => true
|
22
|
-
set :slim, :generator => Temple::Generators::RailsOutputBuffer
|
23
19
|
end
|
24
20
|
|
25
21
|
# get current engines from partials
|
@@ -36,6 +32,10 @@ class RenderDemo < Padrino::Application
|
|
36
32
|
render "double_capture_#{params[:ext]}"
|
37
33
|
end
|
38
34
|
|
35
|
+
get '/wrong_capture_:ext' do
|
36
|
+
render "wrong_capture_#{params[:ext]}"
|
37
|
+
end
|
38
|
+
|
39
39
|
# partial with object
|
40
40
|
get '/partial/object' do
|
41
41
|
partial 'template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
|
@@ -55,4 +55,16 @@ class RenderDemo < Padrino::Application
|
|
55
55
|
get '/partial/foward_slash' do
|
56
56
|
partial '/template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
|
57
57
|
end
|
58
|
+
|
59
|
+
get '/render_block_:ext' do
|
60
|
+
render "render_block_#{params[:ext]}" do
|
61
|
+
content_tag :div, 'go block!'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
get '/partial_block_:ext' do
|
66
|
+
partial "partial_block_#{params[:ext]}" do
|
67
|
+
content_tag :div, 'go block!'
|
68
|
+
end
|
69
|
+
end
|
58
70
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
1
|
+
<% form_for( :object, '/' ) do |f| %>
|
2
2
|
<%= $number_of_captures += 1 %>
|
3
|
-
<% end %>
|
3
|
+
<% end %>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
= form_for :object, '/' do |f|
|
2
2
|
= $number_of_captures += 1
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
= form_for :object, '/' do |f|
|
2
2
|
= $number_of_captures += 1
|