haml 4.0.4 → 4.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/haml/helpers.rb +23 -14
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +3 -10
- data/lib/haml/options.rb +3 -1
- data/lib/haml/temple.rb +85 -0
- data/lib/haml/version.rb +1 -1
- data/test/helper_test.rb +19 -0
- data/test/template_test.rb +23 -0
- metadata +35 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 169c5e7e9f3fc9b45bf286035641b324218cd9e8
|
4
|
+
data.tar.gz: 7042e872b1f8d5dd9c02a14ddfb1c74b12f350ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f15703b302c90f429d23f1c1441c47fa81a68887fcaa3a6e01de719253aa3f8380eb21cac73731de49ef54d2a1e1d5bf9308436a96af4548aec7241ceb986e
|
7
|
+
data.tar.gz: fe401f4715c695be27a04ee9d12acf6a776dafc89e8a7bad4e09916805cab2a03186ab6b509a6215a9d5a943f60607710a5f3c9529f54885cd7b43b55f6fc254
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
3
|
=======
|
4
|
+
## 4.0.5
|
5
|
+
|
6
|
+
Released on Jan 7, 2014 ([diff](https://github.com/haml/haml/compare/4.0.4...4.0.5)).
|
7
|
+
|
8
|
+
* Fix haml_concat appending unescaped HTML after a call to haml_tag.
|
9
|
+
* Fix for bug whereby when HAML :ugly option is "true",
|
10
|
+
ActionView::Helpers::CaptureHelper::capture returns the whole view buffer
|
11
|
+
when passed a block that returns nothing (thanks [Mircea
|
12
|
+
Moise](https://github.com/mmircea16)).
|
4
13
|
|
5
14
|
## 4.0.4
|
6
15
|
|
data/lib/haml/helpers.rb
CHANGED
@@ -365,24 +365,17 @@ MESSAGE
|
|
365
365
|
position = haml_buffer.buffer.length
|
366
366
|
|
367
367
|
haml_buffer.capture_position = position
|
368
|
-
block.call(*args)
|
368
|
+
value = block.call(*args)
|
369
369
|
|
370
370
|
captured = haml_buffer.buffer.slice!(position..-1)
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
captured = captured.split(/^/).reject {|x| x == ""}
|
375
|
-
|
376
|
-
min_tabs = nil
|
377
|
-
captured.each do |line|
|
378
|
-
tabs = line.index(/[^ ]/) || line.length
|
379
|
-
min_tabs ||= tabs
|
380
|
-
min_tabs = min_tabs > tabs ? tabs : min_tabs
|
371
|
+
|
372
|
+
if captured == '' and value != haml_buffer.buffer
|
373
|
+
captured = (value.is_a?(String) ? value : nil)
|
381
374
|
end
|
382
375
|
|
383
|
-
captured.
|
384
|
-
|
385
|
-
|
376
|
+
return nil if captured.nil?
|
377
|
+
return (haml_buffer.options[:ugly] ? captured : prettify(captured))
|
378
|
+
|
386
379
|
end
|
387
380
|
ensure
|
388
381
|
haml_buffer.capture_position = nil
|
@@ -637,6 +630,22 @@ MESSAGE
|
|
637
630
|
_erbout = _erbout = _hamlout.buffer
|
638
631
|
proc { |*args| proc.call(*args) }
|
639
632
|
end
|
633
|
+
|
634
|
+
def prettify(text)
|
635
|
+
text = text.split(/^/)
|
636
|
+
text.delete('')
|
637
|
+
|
638
|
+
min_tabs = nil
|
639
|
+
text.each do |line|
|
640
|
+
tabs = line.index(/[^ ]/) || line.length
|
641
|
+
min_tabs ||= tabs
|
642
|
+
min_tabs = min_tabs > tabs ? tabs : min_tabs
|
643
|
+
end
|
644
|
+
|
645
|
+
text.map do |line|
|
646
|
+
line.slice(min_tabs, line.length)
|
647
|
+
end.join
|
648
|
+
end
|
640
649
|
end
|
641
650
|
end
|
642
651
|
|
@@ -45,8 +45,8 @@ module Haml
|
|
45
45
|
# @yield A block in which all input to `#haml_concat` is treated as raw.
|
46
46
|
# @see Haml::Util#rails_xss_safe?
|
47
47
|
def with_raw_haml_concat
|
48
|
+
old = instance_variable_defined?('@_haml_concat_raw') ? @_haml_concat_raw : false
|
48
49
|
@_haml_concat_raw = true
|
49
|
-
old = @_haml_concat_raw
|
50
50
|
yield
|
51
51
|
ensure
|
52
52
|
@_haml_concat_raw = old
|
@@ -41,16 +41,9 @@ module ActionView
|
|
41
41
|
if Haml::Helpers.block_is_haml?(block)
|
42
42
|
#double assignment is to avoid warnings
|
43
43
|
_hamlout = _hamlout = eval('_hamlout', block.binding) # Necessary since capture_haml checks _hamlout
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
if !buffer.empty?
|
48
|
-
buffer
|
49
|
-
elsif value.is_a?(String)
|
50
|
-
value
|
51
|
-
else
|
52
|
-
nil
|
53
|
-
end
|
44
|
+
|
45
|
+
str = capture_haml(*args, &block)
|
46
|
+
|
54
47
|
# NonCattingString is present in Rails less than 3.1.0. When support
|
55
48
|
# for 3.0 is dropped, this can be removed.
|
56
49
|
return ActionView::NonConcattingString.new(str) if str && defined?(ActionView::NonConcattingString)
|
data/lib/haml/options.rb
CHANGED
@@ -6,7 +6,9 @@ module Haml
|
|
6
6
|
|
7
7
|
@defaults = {
|
8
8
|
:attr_wrapper => "'",
|
9
|
-
:autoclose => %w(
|
9
|
+
:autoclose => %w(area base basefont br col command embed frame
|
10
|
+
hr img input isindex keygen link menuitem meta
|
11
|
+
param source track wbr),
|
10
12
|
:encoding => "UTF-8",
|
11
13
|
:escape_attrs => true,
|
12
14
|
:escape_html => false,
|
data/lib/haml/temple.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'haml'
|
2
|
+
require 'temple'
|
3
|
+
|
4
|
+
module Haml
|
5
|
+
|
6
|
+
module Temple
|
7
|
+
|
8
|
+
module Expressions
|
9
|
+
def on_plain
|
10
|
+
[:static, "\n" + value[:text]]
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_root
|
14
|
+
[:multi]
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_doctype
|
18
|
+
[:html, :doctype, value[:version] || 5]
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_tag
|
22
|
+
exp = [:html, :tag, value[:name], [:html, :attrs]]
|
23
|
+
if value[:value] && value[:value] != ""
|
24
|
+
if value[:parse]
|
25
|
+
exp.push << [:dynamic, value[:value]]
|
26
|
+
else
|
27
|
+
exp.push << [:static, value[:value]]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if attribs = value[:attributes]
|
32
|
+
attribs.each do |key, value|
|
33
|
+
exp.last << [:html, :attr, key, [:static, value]]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
exp
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Parser
|
42
|
+
def initialize(*args)
|
43
|
+
@options = Options.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def call(haml)
|
47
|
+
parser = ::Haml::Parser.new(haml, @options)
|
48
|
+
tree = parser.parse.tap {|x| p x; puts '-' * 10}
|
49
|
+
compile(tree).tap {|x| p x; puts '-' * 10}
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def compile(node)
|
55
|
+
exp = node.to_temple
|
56
|
+
return exp if node.children.empty?
|
57
|
+
if node.children.length == 1
|
58
|
+
exp.push compile(node.children[0])
|
59
|
+
else
|
60
|
+
exp.push [:multi, *node.children.map {|c| compile(c)}]
|
61
|
+
end
|
62
|
+
exp
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Engine < ::Temple::Engine
|
67
|
+
use ::Haml::Temple::Parser
|
68
|
+
html :Pretty
|
69
|
+
filter :ControlFlow
|
70
|
+
generator :ArrayBuffer
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Parser::ParseNode
|
75
|
+
include ::Haml::Temple::Expressions
|
76
|
+
|
77
|
+
def to_temple
|
78
|
+
begin
|
79
|
+
send "on_#{type}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Haml::Temple::Template = Temple::Templates::Tilt(Haml::Temple::Engine, :register_as => :haml)
|
data/lib/haml/version.rb
CHANGED
data/test/helper_test.rb
CHANGED
@@ -14,6 +14,16 @@ module Haml::Helpers
|
|
14
14
|
def something_that_uses_haml_concat
|
15
15
|
haml_concat('foo').to_s
|
16
16
|
end
|
17
|
+
|
18
|
+
def render_something_with_haml_concat
|
19
|
+
haml_concat "<p>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def render_something_with_haml_tag_and_concat
|
23
|
+
haml_tag 'p' do
|
24
|
+
haml_concat '<foo>'
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
28
|
|
19
29
|
class HelperTest < MiniTest::Unit::TestCase
|
@@ -48,6 +58,15 @@ class HelperTest < MiniTest::Unit::TestCase
|
|
48
58
|
super
|
49
59
|
end
|
50
60
|
|
61
|
+
def test_rendering_with_escapes
|
62
|
+
output = render(<<-HAML, :action_view)
|
63
|
+
- render_something_with_haml_concat
|
64
|
+
- render_something_with_haml_tag_and_concat
|
65
|
+
- render_something_with_haml_concat
|
66
|
+
HAML
|
67
|
+
assert_equal("<p>\n<p>\n <foo>\n</p>\n<p>\n", output)
|
68
|
+
end
|
69
|
+
|
51
70
|
def test_flatten
|
52
71
|
assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))
|
53
72
|
|
data/test/template_test.rb
CHANGED
@@ -116,6 +116,29 @@ class TemplateTest < MiniTest::Unit::TestCase
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
def test_render_method_returning_null_with_ugly
|
120
|
+
@base.instance_eval do
|
121
|
+
def empty
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
def render_something(&block)
|
125
|
+
capture(self, &block)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
content_to_render = "%h1 This is part of the broken view.\n= render_something do |thing|\n = thing.empty do\n = 'test'"
|
130
|
+
result = render(content_to_render, :ugly => true)
|
131
|
+
expected_result = "<h1>This is part of the broken view.</h1>\n"
|
132
|
+
assert_equal(expected_result, result)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_simple_rendering_with_ugly
|
136
|
+
content_to_render = "%p test\n= capture { 'foo' }"
|
137
|
+
result = render(content_to_render, :ugly => true)
|
138
|
+
expected_result = "<p>test</p>\nfoo\n"
|
139
|
+
assert_equal(expected_result, result)
|
140
|
+
end
|
141
|
+
|
119
142
|
def test_templates_should_render_correctly_with_render_proc
|
120
143
|
assert_renders_correctly("standard") do |name|
|
121
144
|
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :format => :xhtml)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,73 +10,73 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
type: :runtime
|
17
16
|
name: tilt
|
18
|
-
prerelease: false
|
19
17
|
requirement: !ruby/object:Gem::Requirement
|
20
18
|
requirements:
|
21
19
|
- - ">="
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
type: :development
|
31
30
|
name: rails
|
32
|
-
prerelease: false
|
33
31
|
requirement: !ruby/object:Gem::Requirement
|
34
32
|
requirements:
|
35
33
|
- - ">="
|
36
34
|
- !ruby/object:Gem::Version
|
37
35
|
version: 3.0.0
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 3.0.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
type: :development
|
45
44
|
name: rbench
|
46
|
-
prerelease: false
|
47
45
|
requirement: !ruby/object:Gem::Requirement
|
48
46
|
requirements:
|
49
47
|
- - ">="
|
50
48
|
- !ruby/object:Gem::Version
|
51
49
|
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
type: :development
|
59
58
|
name: minitest
|
60
|
-
prerelease: false
|
61
59
|
requirement: !ruby/object:Gem::Requirement
|
62
60
|
requirements:
|
63
61
|
- - ">="
|
64
62
|
- !ruby/object:Gem::Version
|
65
63
|
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
type: :development
|
73
72
|
name: nokogiri
|
74
|
-
prerelease: false
|
75
73
|
requirement: !ruby/object:Gem::Requirement
|
76
74
|
requirements:
|
77
75
|
- - "~>"
|
78
76
|
- !ruby/object:Gem::Version
|
79
77
|
version: 1.5.10
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
@@ -96,6 +96,14 @@ executables:
|
|
96
96
|
extensions: []
|
97
97
|
extra_rdoc_files: []
|
98
98
|
files:
|
99
|
+
- ".yardopts"
|
100
|
+
- CHANGELOG.md
|
101
|
+
- FAQ.md
|
102
|
+
- MIT-LICENSE
|
103
|
+
- README.md
|
104
|
+
- REFERENCE.md
|
105
|
+
- Rakefile
|
106
|
+
- bin/haml
|
99
107
|
- lib/haml.rb
|
100
108
|
- lib/haml/buffer.rb
|
101
109
|
- lib/haml/compiler.rb
|
@@ -104,39 +112,36 @@ files:
|
|
104
112
|
- lib/haml/exec.rb
|
105
113
|
- lib/haml/filters.rb
|
106
114
|
- lib/haml/helpers.rb
|
107
|
-
- lib/haml/options.rb
|
108
|
-
- lib/haml/parser.rb
|
109
|
-
- lib/haml/railtie.rb
|
110
|
-
- lib/haml/sass_rails_filter.rb
|
111
|
-
- lib/haml/template.rb
|
112
|
-
- lib/haml/util.rb
|
113
|
-
- lib/haml/version.rb
|
114
115
|
- lib/haml/helpers/action_view_extensions.rb
|
115
116
|
- lib/haml/helpers/action_view_mods.rb
|
116
117
|
- lib/haml/helpers/action_view_xss_mods.rb
|
117
118
|
- lib/haml/helpers/safe_erubis_template.rb
|
118
119
|
- lib/haml/helpers/xss_mods.rb
|
120
|
+
- lib/haml/options.rb
|
121
|
+
- lib/haml/parser.rb
|
122
|
+
- lib/haml/railtie.rb
|
123
|
+
- lib/haml/sass_rails_filter.rb
|
124
|
+
- lib/haml/template.rb
|
119
125
|
- lib/haml/template/options.rb
|
120
126
|
- lib/haml/template/plugin.rb
|
121
|
-
-
|
127
|
+
- lib/haml/temple.rb
|
128
|
+
- lib/haml/util.rb
|
129
|
+
- lib/haml/version.rb
|
122
130
|
- test/engine_test.rb
|
123
|
-
- test/filters_test.rb
|
124
|
-
- test/helper_test.rb
|
125
|
-
- test/parser_test.rb
|
126
|
-
- test/template_test.rb
|
127
|
-
- test/test_helper.rb
|
128
|
-
- test/util_test.rb
|
129
131
|
- test/erb/_av_partial_1.erb
|
130
132
|
- test/erb/_av_partial_2.erb
|
131
133
|
- test/erb/action_view.erb
|
132
134
|
- test/erb/standard.erb
|
135
|
+
- test/filters_test.rb
|
133
136
|
- test/gemfiles/Gemfile.rails-3.0.x
|
134
137
|
- test/gemfiles/Gemfile.rails-3.1.x
|
135
138
|
- test/gemfiles/Gemfile.rails-3.2.x
|
136
139
|
- test/gemfiles/Gemfile.rails-4.0.x
|
137
140
|
- test/gemfiles/Gemfile.rails-4.0.x.lock
|
141
|
+
- test/helper_test.rb
|
138
142
|
- test/markaby/standard.mab
|
139
143
|
- test/mocks/article.rb
|
144
|
+
- test/parser_test.rb
|
140
145
|
- test/results/content_for_layout.xhtml
|
141
146
|
- test/results/eval_suppressed.xhtml
|
142
147
|
- test/results/helpers.xhtml
|
@@ -155,6 +160,7 @@ files:
|
|
155
160
|
- test/results/tag_parsing.xhtml
|
156
161
|
- test/results/very_basic.xhtml
|
157
162
|
- test/results/whitespace_handling.xhtml
|
163
|
+
- test/template_test.rb
|
158
164
|
- test/templates/_av_partial_1.haml
|
159
165
|
- test/templates/_av_partial_1_ugly.haml
|
160
166
|
- test/templates/_av_partial_2.haml
|
@@ -187,13 +193,8 @@ files:
|
|
187
193
|
- test/templates/tag_parsing.haml
|
188
194
|
- test/templates/very_basic.haml
|
189
195
|
- test/templates/whitespace_handling.haml
|
190
|
-
-
|
191
|
-
-
|
192
|
-
- CHANGELOG.md
|
193
|
-
- FAQ.md
|
194
|
-
- MIT-LICENSE
|
195
|
-
- README.md
|
196
|
-
- REFERENCE.md
|
196
|
+
- test/test_helper.rb
|
197
|
+
- test/util_test.rb
|
197
198
|
homepage: http://haml.info/
|
198
199
|
licenses:
|
199
200
|
- MIT
|
@@ -229,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
230
|
version: '0'
|
230
231
|
requirements: []
|
231
232
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
233
|
+
rubygems_version: 2.2.0
|
233
234
|
signing_key:
|
234
235
|
specification_version: 4
|
235
236
|
summary: An elegant, structured (X)HTML/XML templating engine.
|