haml 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +117 -5
  4. data/FAQ.md +7 -17
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +85 -42
  7. data/REFERENCE.md +181 -86
  8. data/Rakefile +47 -51
  9. data/lib/haml/attribute_builder.rb +163 -0
  10. data/lib/haml/attribute_compiler.rb +215 -0
  11. data/lib/haml/attribute_parser.rb +144 -0
  12. data/lib/haml/buffer.rb +38 -128
  13. data/lib/haml/compiler.rb +88 -295
  14. data/lib/haml/engine.rb +25 -41
  15. data/lib/haml/error.rb +3 -0
  16. data/lib/haml/escapable.rb +49 -0
  17. data/lib/haml/exec.rb +33 -19
  18. data/lib/haml/filters.rb +20 -24
  19. data/lib/haml/generator.rb +41 -0
  20. data/lib/haml/helpers/action_view_extensions.rb +3 -2
  21. data/lib/haml/helpers/action_view_mods.rb +44 -66
  22. data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
  23. data/lib/haml/helpers/safe_erubi_template.rb +27 -0
  24. data/lib/haml/helpers/safe_erubis_template.rb +16 -4
  25. data/lib/haml/helpers/xss_mods.rb +18 -12
  26. data/lib/haml/helpers.rb +122 -58
  27. data/lib/haml/options.rb +39 -46
  28. data/lib/haml/parser.rb +278 -217
  29. data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
  30. data/lib/haml/railtie.rb +21 -11
  31. data/lib/haml/sass_rails_filter.rb +17 -4
  32. data/lib/haml/template/options.rb +12 -2
  33. data/lib/haml/template.rb +12 -6
  34. data/lib/haml/temple_engine.rb +120 -0
  35. data/lib/haml/temple_line_counter.rb +29 -0
  36. data/lib/haml/util.rb +80 -199
  37. data/lib/haml/version.rb +2 -1
  38. data/lib/haml.rb +2 -1
  39. data/test/attribute_parser_test.rb +101 -0
  40. data/test/engine_test.rb +306 -176
  41. data/test/filters_test.rb +32 -19
  42. data/test/gemfiles/Gemfile.rails-4.0.x +11 -0
  43. data/test/gemfiles/Gemfile.rails-4.0.x.lock +87 -0
  44. data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
  45. data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
  46. data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
  47. data/test/helper_test.rb +282 -96
  48. data/test/options_test.rb +22 -0
  49. data/test/parser_test.rb +71 -4
  50. data/test/results/bemit.xhtml +4 -0
  51. data/test/results/eval_suppressed.xhtml +4 -4
  52. data/test/results/helpers.xhtml +43 -41
  53. data/test/results/helpful.xhtml +6 -3
  54. data/test/results/just_stuff.xhtml +21 -20
  55. data/test/results/list.xhtml +9 -9
  56. data/test/results/nuke_inner_whitespace.xhtml +22 -22
  57. data/test/results/nuke_outer_whitespace.xhtml +84 -92
  58. data/test/results/original_engine.xhtml +17 -17
  59. data/test/results/partial_layout.xhtml +4 -3
  60. data/test/results/partial_layout_erb.xhtml +4 -3
  61. data/test/results/partials.xhtml +11 -10
  62. data/test/results/silent_script.xhtml +63 -63
  63. data/test/results/standard.xhtml +156 -159
  64. data/test/results/tag_parsing.xhtml +19 -19
  65. data/test/results/very_basic.xhtml +2 -2
  66. data/test/results/whitespace_handling.xhtml +56 -50
  67. data/test/template_test.rb +44 -53
  68. data/test/template_test_helper.rb +38 -0
  69. data/test/templates/_text_area_helper.html.haml +4 -0
  70. data/test/templates/bemit.haml +3 -0
  71. data/test/templates/just_stuff.haml +1 -0
  72. data/test/templates/partial_layout_erb.erb +1 -1
  73. data/test/templates/standard_ugly.haml +1 -0
  74. data/test/templates/with_bom.haml +1 -0
  75. data/test/temple_line_counter_test.rb +40 -0
  76. data/test/test_helper.rb +26 -12
  77. data/test/util_test.rb +6 -47
  78. metadata +88 -106
  79. data/lib/haml/helpers/rails_323_textarea_fix.rb +0 -24
  80. data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
  81. data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
  82. data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
  83. data/test/gemfiles/Gemfile.rails-master +0 -4
  84. data/test/templates/_av_partial_1_ugly.haml +0 -9
  85. data/test/templates/_av_partial_2_ugly.haml +0 -5
  86. data/test/templates/action_view_ugly.haml +0 -47
  87. data/test/templates/standard_ugly.haml +0 -43
metadata CHANGED
@@ -1,110 +1,108 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 4.0.0
4
+ version: 5.0.0
6
5
  platform: ruby
7
6
  authors:
8
- - Nathan Weizenbaum
7
+ - Natalie Weizenbaum
9
8
  - Hampton Catlin
10
9
  - Norman Clarke
10
+ - Akira Matsuda
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-13 00:00:00.000000000 Z
14
+ date: 2017-04-27 00:00:00.000000000 Z
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: temple
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.0
16
30
  - !ruby/object:Gem::Dependency
17
31
  name: tilt
18
32
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
33
  requirements:
21
- - - ! '>='
34
+ - - ">="
22
35
  - !ruby/object:Gem::Version
23
36
  version: '0'
37
+ type: :runtime
38
+ prerelease: false
24
39
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
40
  requirements:
27
- - - ! '>='
41
+ - - ">="
28
42
  - !ruby/object:Gem::Version
29
43
  version: '0'
30
- prerelease: false
31
- type: :runtime
32
44
  - !ruby/object:Gem::Dependency
33
45
  name: rails
34
46
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
47
  requirements:
37
- - - ! '>='
48
+ - - ">="
38
49
  - !ruby/object:Gem::Version
39
- version: 3.0.0
50
+ version: 4.0.0
51
+ type: :development
52
+ prerelease: false
40
53
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
54
  requirements:
43
- - - ! '>='
55
+ - - ">="
44
56
  - !ruby/object:Gem::Version
45
- version: 3.0.0
46
- prerelease: false
47
- type: :development
57
+ version: 4.0.0
48
58
  - !ruby/object:Gem::Dependency
49
59
  name: rbench
50
60
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
61
  requirements:
53
- - - ! '>='
62
+ - - ">="
54
63
  - !ruby/object:Gem::Version
55
64
  version: '0'
65
+ type: :development
66
+ prerelease: false
56
67
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
68
  requirements:
59
- - - ! '>='
69
+ - - ">="
60
70
  - !ruby/object:Gem::Version
61
71
  version: '0'
62
- prerelease: false
63
- type: :development
64
72
  - !ruby/object:Gem::Dependency
65
73
  name: minitest
66
74
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
75
  requirements:
69
- - - ! '>='
76
+ - - ">="
70
77
  - !ruby/object:Gem::Version
71
- version: '0'
78
+ version: '4.0'
79
+ type: :development
80
+ prerelease: false
72
81
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
82
  requirements:
75
- - - ! '>='
83
+ - - ">="
76
84
  - !ruby/object:Gem::Version
77
- version: '0'
78
- prerelease: false
79
- type: :development
85
+ version: '4.0'
80
86
  - !ruby/object:Gem::Dependency
81
87
  name: nokogiri
82
88
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
89
  requirements:
85
- - - ! '>='
90
+ - - ">="
86
91
  - !ruby/object:Gem::Version
87
92
  version: '0'
93
+ type: :development
94
+ prerelease: false
88
95
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
96
  requirements:
91
- - - ! '>='
97
+ - - ">="
92
98
  - !ruby/object:Gem::Version
93
99
  version: '0'
94
- prerelease: false
95
- type: :development
96
- description: ! 'Haml (HTML Abstraction Markup Language) is a layer on top of HTML
97
- or XML that''s
98
-
100
+ description: |
101
+ Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
99
102
  designed to express the structure of documents in a non-repetitive, elegant, and
100
-
101
103
  easy way by using indentation rather than closing tags and allowing Ruby to be
102
-
103
104
  embedded with ease. It was originally envisioned as a plugin for Ruby on Rails,
104
-
105
105
  but it can function as a stand-alone templating engine.
106
-
107
- '
108
106
  email:
109
107
  - haml@googlegroups.com
110
108
  - norman@njclarke.com
@@ -113,44 +111,62 @@ executables:
113
111
  extensions: []
114
112
  extra_rdoc_files: []
115
113
  files:
114
+ - ".yardopts"
115
+ - CHANGELOG.md
116
+ - FAQ.md
117
+ - MIT-LICENSE
118
+ - README.md
119
+ - REFERENCE.md
120
+ - Rakefile
121
+ - bin/haml
122
+ - lib/haml.rb
123
+ - lib/haml/attribute_builder.rb
124
+ - lib/haml/attribute_compiler.rb
125
+ - lib/haml/attribute_parser.rb
116
126
  - lib/haml/buffer.rb
117
127
  - lib/haml/compiler.rb
118
128
  - lib/haml/engine.rb
119
129
  - lib/haml/error.rb
130
+ - lib/haml/escapable.rb
120
131
  - lib/haml/exec.rb
121
132
  - lib/haml/filters.rb
133
+ - lib/haml/generator.rb
134
+ - lib/haml/helpers.rb
122
135
  - lib/haml/helpers/action_view_extensions.rb
123
136
  - lib/haml/helpers/action_view_mods.rb
124
137
  - lib/haml/helpers/action_view_xss_mods.rb
125
- - lib/haml/helpers/rails_323_textarea_fix.rb
138
+ - lib/haml/helpers/safe_erubi_template.rb
126
139
  - lib/haml/helpers/safe_erubis_template.rb
127
140
  - lib/haml/helpers/xss_mods.rb
128
- - lib/haml/helpers.rb
129
141
  - lib/haml/options.rb
130
142
  - lib/haml/parser.rb
143
+ - lib/haml/plugin.rb
131
144
  - lib/haml/railtie.rb
132
145
  - lib/haml/sass_rails_filter.rb
133
- - lib/haml/template/options.rb
134
- - lib/haml/template/plugin.rb
135
146
  - lib/haml/template.rb
147
+ - lib/haml/template/options.rb
148
+ - lib/haml/temple_engine.rb
149
+ - lib/haml/temple_line_counter.rb
136
150
  - lib/haml/util.rb
137
151
  - lib/haml/version.rb
138
- - lib/haml.rb
139
- - bin/haml
152
+ - test/attribute_parser_test.rb
140
153
  - test/engine_test.rb
141
154
  - test/erb/_av_partial_1.erb
142
155
  - test/erb/_av_partial_2.erb
143
156
  - test/erb/action_view.erb
144
157
  - test/erb/standard.erb
145
158
  - test/filters_test.rb
146
- - test/gemfiles/Gemfile.rails-3.0.x
147
- - test/gemfiles/Gemfile.rails-3.1.x
148
- - test/gemfiles/Gemfile.rails-3.2.x
149
- - test/gemfiles/Gemfile.rails-master
159
+ - test/gemfiles/Gemfile.rails-4.0.x
160
+ - test/gemfiles/Gemfile.rails-4.0.x.lock
161
+ - test/gemfiles/Gemfile.rails-4.1.x
162
+ - test/gemfiles/Gemfile.rails-4.2.x
163
+ - test/gemfiles/Gemfile.rails-5.0.x
150
164
  - test/helper_test.rb
151
165
  - test/markaby/standard.mab
152
166
  - test/mocks/article.rb
167
+ - test/options_test.rb
153
168
  - test/parser_test.rb
169
+ - test/results/bemit.xhtml
154
170
  - test/results/content_for_layout.xhtml
155
171
  - test/results/eval_suppressed.xhtml
156
172
  - test/results/helpers.xhtml
@@ -170,16 +186,16 @@ files:
170
186
  - test/results/very_basic.xhtml
171
187
  - test/results/whitespace_handling.xhtml
172
188
  - test/template_test.rb
189
+ - test/template_test_helper.rb
173
190
  - test/templates/_av_partial_1.haml
174
- - test/templates/_av_partial_1_ugly.haml
175
191
  - test/templates/_av_partial_2.haml
176
- - test/templates/_av_partial_2_ugly.haml
177
192
  - test/templates/_layout.erb
178
193
  - test/templates/_layout_for_partial.haml
179
194
  - test/templates/_partial.haml
180
195
  - test/templates/_text_area.haml
196
+ - test/templates/_text_area_helper.html.haml
181
197
  - test/templates/action_view.haml
182
- - test/templates/action_view_ugly.haml
198
+ - test/templates/bemit.haml
183
199
  - test/templates/breakage.haml
184
200
  - test/templates/content_for_layout.haml
185
201
  - test/templates/eval_suppressed.haml
@@ -201,76 +217,42 @@ files:
201
217
  - test/templates/tag_parsing.haml
202
218
  - test/templates/very_basic.haml
203
219
  - test/templates/whitespace_handling.haml
220
+ - test/templates/with_bom.haml
221
+ - test/temple_line_counter_test.rb
204
222
  - test/test_helper.rb
205
223
  - test/util_test.rb
206
- - Rakefile
207
- - .yardopts
208
- - CHANGELOG.md
209
- - FAQ.md
210
- - MIT-LICENSE
211
- - README.md
212
- - REFERENCE.md
213
224
  homepage: http://haml.info/
214
225
  licenses:
215
226
  - MIT
216
- post_install_message: ! '
217
-
218
- HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
219
-
220
- your application:
221
-
222
-
223
- * Support for Ruby 1.8.6 dropped
224
-
225
- * Support for Rails 2 dropped
226
-
227
- * Sass filter now always outputs <style> tags
228
-
229
- * Data attributes are now hyphenated, not underscored
230
-
231
- * html2haml utility moved to the html2haml gem
232
-
233
- * Textile and Maruku filters moved to the haml-contrib gem
234
-
235
-
236
- For more info see:
237
-
238
-
239
- http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
240
-
241
-
242
- '
227
+ metadata: {}
228
+ post_install_message:
243
229
  rdoc_options: []
244
230
  require_paths:
245
231
  - lib
246
232
  required_ruby_version: !ruby/object:Gem::Requirement
247
- none: false
248
233
  requirements:
249
- - - ! '>='
234
+ - - ">="
250
235
  - !ruby/object:Gem::Version
251
- segments:
252
- - 0
253
- hash: 3355577792412640496
254
- version: '0'
236
+ version: 2.0.0
255
237
  required_rubygems_version: !ruby/object:Gem::Requirement
256
- none: false
257
238
  requirements:
258
- - - ! '>='
239
+ - - ">="
259
240
  - !ruby/object:Gem::Version
260
- segments:
261
- - 0
262
- hash: 3355577792412640496
263
241
  version: '0'
264
242
  requirements: []
265
243
  rubyforge_project:
266
- rubygems_version: 1.8.24
244
+ rubygems_version: 2.6.11
267
245
  signing_key:
268
- specification_version: 3
246
+ specification_version: 4
269
247
  summary: An elegant, structured (X)HTML/XML templating engine.
270
248
  test_files:
249
+ - test/attribute_parser_test.rb
271
250
  - test/engine_test.rb
272
251
  - test/filters_test.rb
273
252
  - test/helper_test.rb
253
+ - test/options_test.rb
274
254
  - test/parser_test.rb
275
255
  - test/template_test.rb
256
+ - test/temple_line_counter_test.rb
276
257
  - test/util_test.rb
258
+ has_rdoc: false
@@ -1,24 +0,0 @@
1
- # As of 3.2.3, Rails's form helpers add a newline after opening textareas,
2
- # which can cause problems with newlines being considered content rather than
3
- # markup. Here we decode the first newline back into a real newline to make the
4
- # textarea work as expected. Note that in order for this to work, the compiler
5
- # code was also change to avoid indenting code with textareas, even when Haml
6
- # is running in indented mode.
7
- module ActionView
8
- module Helpers
9
-
10
- module FormTagHelper
11
- def text_area_tag_with_haml(*args)
12
- text_area_tag_without_haml(*args).sub('>&#x000A;', ">\n").html_safe
13
- end
14
- alias_method_chain :text_area_tag, :haml
15
- end
16
-
17
- module FormHelper
18
- def text_area_with_haml(*args)
19
- text_area_without_haml(*args).sub('>&#x000A;', ">\n").html_safe
20
- end
21
- alias_method_chain :text_area, :haml
22
- end
23
- end
24
- end
@@ -1,5 +0,0 @@
1
- source :rubygems
2
-
3
- gem 'rails', '>= 3.0.0', '< 3.1.0'
4
- gemspec :path => "../.."
5
-
@@ -1,6 +0,0 @@
1
- source :rubygems
2
-
3
- gem 'rails', '>= 3.1.0', '< 3.2.0'
4
- gemspec :path => "../.."
5
-
6
-
@@ -1,5 +0,0 @@
1
- source :rubygems
2
-
3
- gem 'rails', '>= 3.2.0', '< 3.3.0'
4
- gemspec :path => "../.."
5
-
@@ -1,4 +0,0 @@
1
- source :rubygems
2
-
3
- gem 'rails', git: 'git://github.com/rails/rails.git'
4
- gemspec :path => '../..'
@@ -1,9 +0,0 @@
1
- %h2 This is a pretty complicated partial
2
- .partial
3
- %p It has several nested partials,
4
- %ul
5
- - 5.times do
6
- %li
7
- %strong Partial:
8
- - @nesting = 5
9
- = render :partial => 'templates/av_partial_2_ugly'
@@ -1,5 +0,0 @@
1
- - @nesting -= 1
2
- .partial{:level => @nesting}
3
- %h3 This is a crazy deep-nested partial.
4
- %p== Nesting level #{@nesting}
5
- = render :partial => 'templates/av_partial_2_ugly' if @nesting > 0
@@ -1,47 +0,0 @@
1
- !!!
2
- %html{html_attrs}
3
- %head
4
- %title Hampton Catlin Is Totally Awesome
5
- %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
6
- %body
7
- %h1
8
- This is very much like the standard template,
9
- except that it has some ActionView-specific stuff.
10
- It's only used for benchmarking.
11
- .crazy_partials= render :partial => 'templates/av_partial_1_ugly'
12
- / You're In my house now!
13
- .header
14
- Yes, ladies and gentileman. He is just that egotistical.
15
- Fantastic! This should be multi-line output
16
- The question is if this would translate! Ahah!
17
- = 1 + 9 + 8 + 2 #numbers should work and this should be ignored
18
- #body= " Quotes should be loved! Just like people!"
19
- - 120.times do |number|
20
- - number
21
- Wow.|
22
- %p
23
- = "Holy cow " + |
24
- "multiline " + |
25
- "tags! " + |
26
- "A pipe (|) even!" |
27
- = [1, 2, 3].collect { |n| "PipesIgnored|" }
28
- = [1, 2, 3].collect { |n| |
29
- n.to_s |
30
- }.join("|") |
31
- %div.silent
32
- - foo = String.new
33
- - foo << "this"
34
- - foo << " shouldn't"
35
- - foo << " evaluate"
36
- = foo + " but now it should!"
37
- -# Woah crap a comment!
38
-
39
- -# That was a line that shouldn't close everything.
40
- %ul.really.cool
41
- - ('a'..'f').each do |a|
42
- %li= a
43
- #combo.of_divs_with_underscore= @should_eval = "with this text"
44
- = [ 104, 101, 108, 108, 111 ].map do |byte|
45
- - byte.chr
46
- .footer
47
- %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"
@@ -1,43 +0,0 @@
1
- !!!
2
- %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en-US", "lang" => "en-US"}
3
- %head
4
- %title Hampton Catlin Is Totally Awesome
5
- %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
6
- %body
7
- / You're In my house now!
8
- .header
9
- Yes, ladies and gentileman. He is just that egotistical.
10
- Fantastic! This should be multi-line output
11
- The question is if this would translate! Ahah!
12
- = 1 + 9 + 8 + 2 #numbers should work and this should be ignored
13
- #body= " Quotes should be loved! Just like people!"
14
- - 120.times do |number|
15
- = number
16
- Wow.|
17
- %p{:code => 1 + 2}
18
- = "Holy cow " + |
19
- "multiline " + |
20
- "tags! " + |
21
- "A pipe (|) even!" |
22
- = [1, 2, 3].collect { |n| "PipesIgnored|" }.join
23
- = [1, 2, 3].collect { |n| |
24
- n.to_s |
25
- }.join("|") |
26
- - bar = 17
27
- %div.silent{:foo => bar}
28
- - foo = String.new
29
- - foo << "this"
30
- - foo << " shouldn't"
31
- - foo << " evaluate"
32
- = foo + " but now it should!"
33
- -# Woah crap a comment!
34
-
35
- -# That was a line that shouldn't close everything.
36
- %ul.really.cool
37
- - ('a'..'f').each do |a|
38
- %li= a
39
- #combo.of_divs_with_underscore= @should_eval = "with this text"
40
- = "foo".each_line do |line|
41
- - nil
42
- .footer
43
- %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"