padrino-helpers 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/padrino-helpers/asset_tag_helpers.rb +1 -1
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +3 -3
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +3 -3
- data/lib/padrino-helpers/form_helpers.rb +1 -1
- data/lib/padrino-helpers/format_helpers.rb +1 -1
- data/lib/padrino-helpers/locale/da.yml +1 -1
- data/lib/padrino-helpers/locale/en.yml +1 -1
- data/lib/padrino-helpers/locale/es.yml +1 -1
- data/lib/padrino-helpers/locale/hu.yml +1 -1
- data/lib/padrino-helpers/locale/it.yml +1 -1
- data/lib/padrino-helpers/locale/no.yml +1 -1
- data/lib/padrino-helpers/locale/pl.yml +1 -1
- data/lib/padrino-helpers/locale/pt_br.yml +1 -1
- data/lib/padrino-helpers/locale/ru.yml +1 -1
- data/lib/padrino-helpers/locale/tr.yml +1 -1
- data/lib/padrino-helpers/locale/uk.yml +1 -1
- data/lib/padrino-helpers/number_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers/haml_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers.rb +3 -3
- data/lib/padrino-helpers/render_helpers.rb +2 -1
- data/lib/padrino-helpers/tag_helpers.rb +18 -2
- data/lib/padrino-helpers/translation_helpers.rb +1 -1
- data/lib/padrino-helpers.rb +1 -1
- data/padrino-helpers.gemspec +2 -2
- data/test/fixtures/markup_app/app.rb +1 -1
- data/test/fixtures/markup_app/views/capture_concat.erb +1 -1
- data/test/fixtures/markup_app/views/content_for.erb +1 -1
- data/test/fixtures/markup_app/views/content_for.haml +1 -1
- data/test/fixtures/markup_app/views/content_for.slim +1 -1
- data/test/fixtures/markup_app/views/content_tag.erb +1 -1
- data/test/fixtures/markup_app/views/current_engine.erb +1 -1
- data/test/fixtures/markup_app/views/current_engine.haml +1 -1
- data/test/fixtures/markup_app/views/current_engine.slim +1 -1
- data/test/fixtures/markup_app/views/fields_for.erb +1 -1
- data/test/fixtures/markup_app/views/fields_for.haml +1 -1
- data/test/fixtures/markup_app/views/fields_for.slim +1 -1
- data/test/fixtures/markup_app/views/form_for.erb +1 -1
- data/test/fixtures/markup_app/views/form_for.haml +1 -1
- data/test/fixtures/markup_app/views/form_for.slim +1 -1
- data/test/fixtures/markup_app/views/form_tag.erb +1 -1
- data/test/fixtures/markup_app/views/form_tag.haml +1 -1
- data/test/fixtures/markup_app/views/form_tag.slim +1 -1
- data/test/fixtures/markup_app/views/link_to.erb +1 -1
- data/test/fixtures/markup_app/views/link_to.haml +1 -1
- data/test/fixtures/markup_app/views/link_to.slim +1 -1
- data/test/fixtures/markup_app/views/mail_to.erb +1 -1
- data/test/fixtures/markup_app/views/mail_to.haml +1 -1
- data/test/fixtures/markup_app/views/mail_to.slim +1 -1
- data/test/fixtures/markup_app/views/meta_tag.erb +1 -1
- data/test/fixtures/markup_app/views/meta_tag.haml +1 -1
- data/test/fixtures/markup_app/views/meta_tag.slim +1 -1
- data/test/fixtures/markup_app/views/partials/_erb.erb +1 -1
- data/test/fixtures/markup_app/views/partials/_haml.haml +1 -1
- data/test/fixtures/markup_app/views/partials/_slim.slim +1 -1
- data/test/fixtures/markup_app/views/simple_partial.erb +1 -1
- data/test/fixtures/markup_app/views/simple_partial.haml +1 -1
- data/test/fixtures/markup_app/views/simple_partial.slim +1 -1
- data/test/fixtures/render_app/app.rb +6 -1
- data/test/fixtures/render_app/views/current_engine.haml +1 -1
- data/test/fixtures/render_app/views/current_engines/_erb.erb +1 -1
- data/test/fixtures/render_app/views/current_engines/_haml.haml +1 -1
- data/test/fixtures/render_app/views/current_engines/_slim.slim +1 -1
- data/test/fixtures/render_app/views/erb/test.erb +1 -1
- data/test/fixtures/render_app/views/explicit_engine.haml +1 -1
- data/test/fixtures/render_app/views/haml/test.haml +1 -1
- data/test/fixtures/render_app/views/template/_user.haml +1 -1
- data/test/fixtures/render_app/views/template/haml_template.haml +1 -1
- data/test/fixtures/render_app/views/template/some_template.haml +1 -1
- data/test/helper.rb +2 -2
- data/test/test_asset_tag_helpers.rb +1 -1
- data/test/test_form_helpers.rb +1 -1
- data/test/test_format_helpers.rb +1 -1
- data/test/test_number_helpers.rb +1 -1
- data/test/test_output_helpers.rb +1 -1
- data/test/test_render_helpers.rb +8 -1
- data/test/test_tag_helpers.rb +6 -1
- metadata +26 -4
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Helpers
|
3
|
-
module FormBuilder
|
4
|
-
class AbstractFormBuilder
|
3
|
+
module FormBuilder # @private
|
4
|
+
class AbstractFormBuilder # @private
|
5
5
|
attr_accessor :template, :object
|
6
6
|
|
7
7
|
def initialize(template, object, options={})
|
@@ -217,4 +217,4 @@ module Padrino
|
|
217
217
|
end # AbstractFormBuilder
|
218
218
|
end # FormBuilder
|
219
219
|
end # Helpers
|
220
|
-
end # Padrino
|
220
|
+
end # Padrino
|
@@ -2,8 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/abstract_form_builder') unle
|
|
2
2
|
|
3
3
|
module Padrino
|
4
4
|
module Helpers
|
5
|
-
module FormBuilder
|
6
|
-
class StandardFormBuilder < AbstractFormBuilder
|
5
|
+
module FormBuilder # @private
|
6
|
+
class StandardFormBuilder < AbstractFormBuilder # @private
|
7
7
|
|
8
8
|
##
|
9
9
|
# StandardFormBuilder
|
@@ -40,4 +40,4 @@ module Padrino
|
|
40
40
|
end # StandardFormBuilder
|
41
41
|
end # FormBuilder
|
42
42
|
end # Helpers
|
43
|
-
end # Padrino
|
43
|
+
end # Padrino
|
@@ -100,4 +100,4 @@ en:
|
|
100
100
|
header:
|
101
101
|
one: "1 error prohibited this %{model} from being saved"
|
102
102
|
other: "%{count} errors prohibited this %{model} from being saved"
|
103
|
-
body: "There were problems with the following fields:"
|
103
|
+
body: "There were problems with the following fields:"
|
@@ -2,7 +2,7 @@ module Padrino
|
|
2
2
|
module Helpers
|
3
3
|
module OutputHelpers
|
4
4
|
|
5
|
-
def self.included(base)
|
5
|
+
def self.included(base) # @private
|
6
6
|
base.send(:include, SinatraCurrentEngine) unless base.method_defined?(:current_engine)
|
7
7
|
end
|
8
8
|
|
@@ -12,7 +12,7 @@ module Padrino
|
|
12
12
|
module SinatraCurrentEngine
|
13
13
|
attr_reader :current_engine
|
14
14
|
|
15
|
-
def render(engine, *)
|
15
|
+
def render(engine, *) # @private
|
16
16
|
@current_engine, engine_was = engine, @current_engine
|
17
17
|
output = super
|
18
18
|
@current_engine = engine_was
|
@@ -125,4 +125,4 @@ module Padrino
|
|
125
125
|
end
|
126
126
|
end # OutputHelpers
|
127
127
|
end # Helpers
|
128
|
-
end # Padrino
|
128
|
+
end # Padrino
|
@@ -12,6 +12,7 @@ module Padrino
|
|
12
12
|
# partial 'photo/item', :engine => :erb
|
13
13
|
#
|
14
14
|
def partial(template, options={})
|
15
|
+
logger.debug "PARTIAL: #{template} called" if defined?(logger)
|
15
16
|
options.reverse_merge!(:locals => {}, :layout => false)
|
16
17
|
path = template.to_s.split(File::SEPARATOR)
|
17
18
|
object_name = path[-1].to_sym
|
@@ -37,4 +38,4 @@ module Padrino
|
|
37
38
|
alias :render_partial :partial
|
38
39
|
end # RenderHelpers
|
39
40
|
end # Helpers
|
40
|
-
end # Padrino
|
41
|
+
end # Padrino
|
@@ -1,6 +1,15 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Helpers
|
3
3
|
module TagHelpers
|
4
|
+
##
|
5
|
+
# Tag values escaped to html entities
|
6
|
+
#
|
7
|
+
ESCAPE_VALUES = {
|
8
|
+
"<" => "<",
|
9
|
+
">" => ">",
|
10
|
+
'"' => """
|
11
|
+
}
|
12
|
+
|
4
13
|
##
|
5
14
|
# Creates an html input field with given type and options
|
6
15
|
#
|
@@ -42,7 +51,7 @@ module Padrino
|
|
42
51
|
content, open_tag = options.delete(:content), options.delete(:open)
|
43
52
|
content = content.join("\n") if content.respond_to?(:join)
|
44
53
|
identity_tag_attributes.each { |attr| options[attr] = attr.to_s if options[attr] }
|
45
|
-
html_attrs = options.map { |a, v| v.nil? || v == false ? nil : "#{a}=\"#{v}\"" }.compact.join(" ")
|
54
|
+
html_attrs = options.map { |a, v| v.nil? || v == false ? nil : "#{a}=\"#{escape_value(v)}\"" }.compact.join(" ")
|
46
55
|
base_tag = (html_attrs.present? ? "<#{name} #{html_attrs}" : "<#{name}")
|
47
56
|
base_tag << (open_tag ? ">" : (content ? ">#{content}</#{name}>" : " />"))
|
48
57
|
end
|
@@ -54,6 +63,13 @@ module Padrino
|
|
54
63
|
def identity_tag_attributes
|
55
64
|
[:checked, :disabled, :selected, :multiple]
|
56
65
|
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Escape tag values to their HTML/XML entities.
|
69
|
+
#
|
70
|
+
def escape_value(string)
|
71
|
+
string.to_s.gsub(Regexp.union(*ESCAPE_VALUES.keys)){|c| ESCAPE_VALUES[c] }
|
72
|
+
end
|
57
73
|
end # TagHelpers
|
58
74
|
end # Helpers
|
59
|
-
end # Padrino
|
75
|
+
end # Padrino
|
data/lib/padrino-helpers.rb
CHANGED
data/padrino-helpers.gemspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<%= current_engine %>
|
1
|
+
<%= current_engine %>
|
@@ -1 +1 @@
|
|
1
|
-
=current_engine
|
1
|
+
=current_engine
|
@@ -1 +1 @@
|
|
1
|
-
=current_engine
|
1
|
+
=current_engine
|
@@ -1 +1 @@
|
|
1
|
-
<p class="erb"><%= partial 'partials/erb', :engine => "erb" %></p>
|
1
|
+
<p class="erb"><%= partial 'partials/erb', :engine => "erb" %></p>
|
@@ -1 +1 @@
|
|
1
|
-
%p.haml= partial 'partials/haml', :engine => "haml"
|
1
|
+
%p.haml= partial 'partials/haml', :engine => "haml"
|
@@ -1 +1 @@
|
|
1
|
-
p.slim= partial 'partials/slim', :engine => "slim"
|
1
|
+
p.slim= partial 'partials/slim', :engine => "slim"
|
@@ -42,4 +42,9 @@ class RenderDemo < Padrino::Application
|
|
42
42
|
get '/partial/locals' do
|
43
43
|
partial 'template/user', :locals => { :user => RenderUser.new('John'), :extra => "bar" }
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
|
+
# partial starting with forward slash
|
47
|
+
get '/partial/foward_slash' do
|
48
|
+
partial '/template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
|
49
|
+
end
|
50
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
<span><%= current_engine %></span>
|
1
|
+
<span><%= current_engine %></span>
|
@@ -1 +1 @@
|
|
1
|
-
%span=current_engine
|
1
|
+
%span=current_engine
|
@@ -1 +1 @@
|
|
1
|
-
span=current_engine
|
1
|
+
span=current_engine
|
@@ -1 +1 @@
|
|
1
|
-
<h1>This is a <%= @template %> template!</h1>
|
1
|
+
<h1>This is a <%= @template %> template!</h1>
|
@@ -1 +1 @@
|
|
1
|
-
%h1 This is a #{@template} template!
|
1
|
+
%h1 This is a #{@template} template!
|
@@ -1 +1 @@
|
|
1
|
-
%h1 This is a #{@template} template sent from render_template!
|
1
|
+
%h1 This is a #{@template} template sent from render_template!
|
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
%h1 This is a haml template which was detected!
|
2
|
+
%h1 This is a haml template which was detected!
|
data/test/helper.rb
CHANGED
@@ -317,4 +317,4 @@ class TestAssetTagHelpers < Test::Unit::TestCase
|
|
317
317
|
assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" }
|
318
318
|
end
|
319
319
|
end
|
320
|
-
end
|
320
|
+
end
|
data/test/test_form_helpers.rb
CHANGED
data/test/test_format_helpers.rb
CHANGED
data/test/test_number_helpers.rb
CHANGED
data/test/test_output_helpers.rb
CHANGED
data/test/test_render_helpers.rb
CHANGED
@@ -47,6 +47,13 @@ class TestRenderHelpers < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
context 'for #partial method taking a path starting with forward slash' do
|
51
|
+
setup { visit '/partial/foward_slash' }
|
52
|
+
should "render partial without throwing an error" do
|
53
|
+
assert_have_selector "h1", :content => "User name is John"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
50
57
|
context 'for #current_engine method' do
|
51
58
|
should 'detect correctly current engine for a padrino application' do
|
52
59
|
visit '/current_engine'
|
@@ -66,4 +73,4 @@ class TestRenderHelpers < Test::Unit::TestCase
|
|
66
73
|
assert_have_selector 'p.end', :content => "haml"
|
67
74
|
end
|
68
75
|
end
|
69
|
-
end
|
76
|
+
end
|
data/test/test_tag_helpers.rb
CHANGED
@@ -34,6 +34,11 @@ class TestTagHelpers < Test::Unit::TestCase
|
|
34
34
|
actual_html = tag(:p, :class => 'demo', :open => true)
|
35
35
|
assert_equal "<p class=\"demo\">", actual_html
|
36
36
|
end
|
37
|
+
|
38
|
+
should "escape html" do
|
39
|
+
actual_html = tag(:br, :class => 'Example "bar"')
|
40
|
+
assert_equal "<br class=\"Example "bar"\" />", actual_html
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
context 'for #content_tag method' do
|
@@ -97,4 +102,4 @@ class TestTagHelpers < Test::Unit::TestCase
|
|
97
102
|
assert_has_tag('input[type=checkbox]', :disabled => 'disabled') { actual_html }
|
98
103
|
end
|
99
104
|
end
|
100
|
-
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 51
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 10
|
9
|
+
- 2
|
10
|
+
version: 0.10.2
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Padrino Team
|
@@ -13,7 +18,7 @@ autorequire:
|
|
13
18
|
bindir: bin
|
14
19
|
cert_chain: []
|
15
20
|
|
16
|
-
date: 2011-08-
|
21
|
+
date: 2011-08-31 00:00:00 -07:00
|
17
22
|
default_executable:
|
18
23
|
dependencies:
|
19
24
|
- !ruby/object:Gem::Dependency
|
@@ -24,7 +29,12 @@ dependencies:
|
|
24
29
|
requirements:
|
25
30
|
- - "="
|
26
31
|
- !ruby/object:Gem::Version
|
27
|
-
|
32
|
+
hash: 51
|
33
|
+
segments:
|
34
|
+
- 0
|
35
|
+
- 10
|
36
|
+
- 2
|
37
|
+
version: 0.10.2
|
28
38
|
type: :runtime
|
29
39
|
version_requirements: *id001
|
30
40
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +45,11 @@ dependencies:
|
|
35
45
|
requirements:
|
36
46
|
- - ~>
|
37
47
|
- !ruby/object:Gem::Version
|
38
|
-
|
48
|
+
hash: 7
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
- 6
|
52
|
+
version: "0.6"
|
39
53
|
type: :runtime
|
40
54
|
version_requirements: *id002
|
41
55
|
description: Tag helpers, asset helpers, form helpers, form builders and many more helpers for padrino
|
@@ -158,12 +172,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
172
|
requirements:
|
159
173
|
- - ">="
|
160
174
|
- !ruby/object:Gem::Version
|
175
|
+
hash: 3
|
176
|
+
segments:
|
177
|
+
- 0
|
161
178
|
version: "0"
|
162
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
180
|
none: false
|
164
181
|
requirements:
|
165
182
|
- - ">="
|
166
183
|
- !ruby/object:Gem::Version
|
184
|
+
hash: 23
|
185
|
+
segments:
|
186
|
+
- 1
|
187
|
+
- 3
|
188
|
+
- 6
|
167
189
|
version: 1.3.6
|
168
190
|
requirements: []
|
169
191
|
|