haml 4.0.7 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +42 -4
  4. data/FAQ.md +4 -14
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +85 -42
  7. data/REFERENCE.md +108 -57
  8. data/Rakefile +46 -54
  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 +22 -132
  13. data/lib/haml/compiler.rb +87 -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 +18 -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 +36 -58
  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 +4 -1
  25. data/lib/haml/helpers/xss_mods.rb +18 -12
  26. data/lib/haml/helpers.rb +133 -90
  27. data/lib/haml/options.rb +38 -47
  28. data/lib/haml/parser.rb +278 -216
  29. data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
  30. data/lib/haml/railtie.rb +21 -12
  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 +1 -0
  39. data/test/attribute_parser_test.rb +101 -0
  40. data/test/engine_test.rb +287 -176
  41. data/test/filters_test.rb +32 -19
  42. data/test/gemfiles/Gemfile.rails-4.0.x +9 -3
  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 +224 -112
  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 +77 -76
  67. data/test/template_test.rb +24 -56
  68. data/test/template_test_helper.rb +38 -0
  69. data/test/templates/bemit.haml +3 -0
  70. data/test/templates/just_stuff.haml +1 -0
  71. data/test/templates/standard_ugly.haml +1 -0
  72. data/test/templates/with_bom.haml +1 -0
  73. data/test/temple_line_counter_test.rb +40 -0
  74. data/test/test_helper.rb +26 -8
  75. data/test/util_test.rb +6 -47
  76. metadata +53 -43
  77. data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
  78. data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
  79. data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
  80. data/test/haml-spec/LICENSE +0 -14
  81. data/test/haml-spec/README.md +0 -106
  82. data/test/haml-spec/lua_haml_spec.lua +0 -38
  83. data/test/haml-spec/perl_haml_test.pl +0 -81
  84. data/test/haml-spec/ruby_haml_test.rb +0 -23
  85. data/test/haml-spec/tests.json +0 -660
  86. data/test/templates/_av_partial_1_ugly.haml +0 -9
  87. data/test/templates/_av_partial_2_ugly.haml +0 -5
  88. data/test/templates/action_view_ugly.haml +0 -47
  89. data/test/templates/standard_ugly.haml +0 -43
metadata CHANGED
@@ -1,17 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Nathan Weizenbaum
7
+ - Natalie Weizenbaum
8
8
  - Hampton Catlin
9
9
  - Norman Clarke
10
+ - Akira Matsuda
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-08-10 00:00:00.000000000 Z
14
+ date: 2017-04-27 00:00:00.000000000 Z
14
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
15
30
  - !ruby/object:Gem::Dependency
16
31
  name: tilt
17
32
  requirement: !ruby/object:Gem::Requirement
@@ -32,14 +47,14 @@ dependencies:
32
47
  requirements:
33
48
  - - ">="
34
49
  - !ruby/object:Gem::Version
35
- version: 3.0.0
50
+ version: 4.0.0
36
51
  type: :development
37
52
  prerelease: false
38
53
  version_requirements: !ruby/object:Gem::Requirement
39
54
  requirements:
40
55
  - - ">="
41
56
  - !ruby/object:Gem::Version
42
- version: 3.0.0
57
+ version: 4.0.0
43
58
  - !ruby/object:Gem::Dependency
44
59
  name: rbench
45
60
  requirement: !ruby/object:Gem::Requirement
@@ -60,28 +75,28 @@ dependencies:
60
75
  requirements:
61
76
  - - ">="
62
77
  - !ruby/object:Gem::Version
63
- version: '0'
78
+ version: '4.0'
64
79
  type: :development
65
80
  prerelease: false
66
81
  version_requirements: !ruby/object:Gem::Requirement
67
82
  requirements:
68
83
  - - ">="
69
84
  - !ruby/object:Gem::Version
70
- version: '0'
85
+ version: '4.0'
71
86
  - !ruby/object:Gem::Dependency
72
87
  name: nokogiri
73
88
  requirement: !ruby/object:Gem::Requirement
74
89
  requirements:
75
- - - "~>"
90
+ - - ">="
76
91
  - !ruby/object:Gem::Version
77
- version: 1.5.10
92
+ version: '0'
78
93
  type: :development
79
94
  prerelease: false
80
95
  version_requirements: !ruby/object:Gem::Requirement
81
96
  requirements:
82
- - - "~>"
97
+ - - ">="
83
98
  - !ruby/object:Gem::Version
84
- version: 1.5.10
99
+ version: '0'
85
100
  description: |
86
101
  Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
87
102
  designed to express the structure of documents in a non-repetitive, elegant, and
@@ -105,47 +120,53 @@ files:
105
120
  - Rakefile
106
121
  - bin/haml
107
122
  - lib/haml.rb
123
+ - lib/haml/attribute_builder.rb
124
+ - lib/haml/attribute_compiler.rb
125
+ - lib/haml/attribute_parser.rb
108
126
  - lib/haml/buffer.rb
109
127
  - lib/haml/compiler.rb
110
128
  - lib/haml/engine.rb
111
129
  - lib/haml/error.rb
130
+ - lib/haml/escapable.rb
112
131
  - lib/haml/exec.rb
113
132
  - lib/haml/filters.rb
133
+ - lib/haml/generator.rb
114
134
  - lib/haml/helpers.rb
115
135
  - lib/haml/helpers/action_view_extensions.rb
116
136
  - lib/haml/helpers/action_view_mods.rb
117
137
  - lib/haml/helpers/action_view_xss_mods.rb
138
+ - lib/haml/helpers/safe_erubi_template.rb
118
139
  - lib/haml/helpers/safe_erubis_template.rb
119
140
  - lib/haml/helpers/xss_mods.rb
120
141
  - lib/haml/options.rb
121
142
  - lib/haml/parser.rb
143
+ - lib/haml/plugin.rb
122
144
  - lib/haml/railtie.rb
123
145
  - lib/haml/sass_rails_filter.rb
124
146
  - lib/haml/template.rb
125
147
  - lib/haml/template/options.rb
126
- - lib/haml/template/plugin.rb
148
+ - lib/haml/temple_engine.rb
149
+ - lib/haml/temple_line_counter.rb
127
150
  - lib/haml/util.rb
128
151
  - lib/haml/version.rb
152
+ - test/attribute_parser_test.rb
129
153
  - test/engine_test.rb
130
154
  - test/erb/_av_partial_1.erb
131
155
  - test/erb/_av_partial_2.erb
132
156
  - test/erb/action_view.erb
133
157
  - test/erb/standard.erb
134
158
  - test/filters_test.rb
135
- - test/gemfiles/Gemfile.rails-3.0.x
136
- - test/gemfiles/Gemfile.rails-3.1.x
137
- - test/gemfiles/Gemfile.rails-3.2.x
138
159
  - test/gemfiles/Gemfile.rails-4.0.x
139
- - test/haml-spec/LICENSE
140
- - test/haml-spec/README.md
141
- - test/haml-spec/lua_haml_spec.lua
142
- - test/haml-spec/perl_haml_test.pl
143
- - test/haml-spec/ruby_haml_test.rb
144
- - test/haml-spec/tests.json
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
145
164
  - test/helper_test.rb
146
165
  - test/markaby/standard.mab
147
166
  - test/mocks/article.rb
167
+ - test/options_test.rb
148
168
  - test/parser_test.rb
169
+ - test/results/bemit.xhtml
149
170
  - test/results/content_for_layout.xhtml
150
171
  - test/results/eval_suppressed.xhtml
151
172
  - test/results/helpers.xhtml
@@ -165,17 +186,16 @@ files:
165
186
  - test/results/very_basic.xhtml
166
187
  - test/results/whitespace_handling.xhtml
167
188
  - test/template_test.rb
189
+ - test/template_test_helper.rb
168
190
  - test/templates/_av_partial_1.haml
169
- - test/templates/_av_partial_1_ugly.haml
170
191
  - test/templates/_av_partial_2.haml
171
- - test/templates/_av_partial_2_ugly.haml
172
192
  - test/templates/_layout.erb
173
193
  - test/templates/_layout_for_partial.haml
174
194
  - test/templates/_partial.haml
175
195
  - test/templates/_text_area.haml
176
196
  - test/templates/_text_area_helper.html.haml
177
197
  - test/templates/action_view.haml
178
- - test/templates/action_view_ugly.haml
198
+ - test/templates/bemit.haml
179
199
  - test/templates/breakage.haml
180
200
  - test/templates/content_for_layout.haml
181
201
  - test/templates/eval_suppressed.haml
@@ -197,28 +217,15 @@ files:
197
217
  - test/templates/tag_parsing.haml
198
218
  - test/templates/very_basic.haml
199
219
  - test/templates/whitespace_handling.haml
220
+ - test/templates/with_bom.haml
221
+ - test/temple_line_counter_test.rb
200
222
  - test/test_helper.rb
201
223
  - test/util_test.rb
202
224
  homepage: http://haml.info/
203
225
  licenses:
204
226
  - MIT
205
227
  metadata: {}
206
- post_install_message: |2+
207
-
208
- HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
209
- your application:
210
-
211
- * Support for Ruby 1.8.6 dropped
212
- * Support for Rails 2 dropped
213
- * Sass filter now always outputs <style> tags
214
- * Data attributes are now hyphenated, not underscored
215
- * html2haml utility moved to the html2haml gem
216
- * Textile and Maruku filters moved to the haml-contrib gem
217
-
218
- For more info see:
219
-
220
- http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
221
-
228
+ post_install_message:
222
229
  rdoc_options: []
223
230
  require_paths:
224
231
  - lib
@@ -226,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
233
  requirements:
227
234
  - - ">="
228
235
  - !ruby/object:Gem::Version
229
- version: '0'
236
+ version: 2.0.0
230
237
  required_rubygems_version: !ruby/object:Gem::Requirement
231
238
  requirements:
232
239
  - - ">="
@@ -234,15 +241,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
241
  version: '0'
235
242
  requirements: []
236
243
  rubyforge_project:
237
- rubygems_version: 2.4.7
244
+ rubygems_version: 2.6.11
238
245
  signing_key:
239
246
  specification_version: 4
240
247
  summary: An elegant, structured (X)HTML/XML templating engine.
241
248
  test_files:
249
+ - test/attribute_parser_test.rb
242
250
  - test/engine_test.rb
243
251
  - test/filters_test.rb
244
- - test/haml-spec/ruby_haml_test.rb
245
252
  - test/helper_test.rb
253
+ - test/options_test.rb
246
254
  - test/parser_test.rb
247
255
  - test/template_test.rb
256
+ - test/temple_line_counter_test.rb
248
257
  - test/util_test.rb
258
+ has_rdoc: false
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'rails', '>= 3.0.0', '< 3.1.0'
4
- gemspec :path => "../.."
5
-
@@ -1,6 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'rails', '>= 3.1.0', '< 3.2.0'
4
- gemspec :path => "../.."
5
-
6
-
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'rails', '>= 3.2.0', '< 3.3.0'
4
- gemspec :path => "../.."
5
-
@@ -1,14 +0,0 @@
1
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
- Version 2, December 2004
3
-
4
- Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
-
6
- Everyone is permitted to copy and distribute verbatim or modified
7
- copies of this license document, and changing it is allowed as long
8
- as the name is changed.
9
-
10
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
-
13
- 0. You just DO WHAT THE FUCK YOU WANT TO.
14
-
@@ -1,106 +0,0 @@
1
- # Haml Spec #
2
-
3
- Haml Spec provides a basic suite of tests for Haml interpreters.
4
-
5
- It is intented for developers who are creating or maintaining an implementation
6
- of the [Haml](http://haml-lang.com) markup language.
7
-
8
- At the moment, there are test runners for the [original
9
- Haml](http://github.com/nex3/haml) in Ruby, [Lua
10
- Haml](http://github.com/norman/lua-haml) and the
11
- [Text::Haml](http://github.com/vti/text-haml) Perl port. Support for other
12
- versions of Haml will be added if their developers/maintainers are interested in
13
- using it.
14
-
15
- ## The Tests ##
16
-
17
- The tests are kept in JSON format for portability across languages. Each test
18
- is a JSON object with expected input, output, local variables and configuration
19
- parameters (see below). The test suite only provides tests for features which
20
- are portable, therefore no tests for script are provided, nor for external
21
- filters such as :markdown or :textile.
22
-
23
- The one major exception to this are the tests for interpolation, which you may
24
- need to modify with a regular expression to run under PHP or Perl, which
25
- require a sigil before variable names. These tests are included despite being
26
- less than 100% portable because interpolation is an important part of Haml and
27
- can be tricky to implement. These tests are flagged as "optional" so that you
28
- can avoid running them if your implementation of Haml will not support this
29
- feature.
30
-
31
- ## Running the Tests ##
32
-
33
- ### Ruby ###
34
-
35
- The Ruby test runner uses minitest, the same as the Ruby Haml implementation.
36
- To run the tests you probably only need to install `haml`, `minitest` and
37
- possibly `ruby` if your platform doesn't come with it by default. If you're
38
- using Ruby 1.8.x, you'll also need to install `json`:
39
-
40
- sudo gem install haml
41
- sudo gem install minitest
42
- # for Ruby 1.8.x; check using "ruby --version" if unsure
43
- sudo gem install json
44
-
45
- Then, running the Ruby test suite is easy:
46
-
47
- ruby ruby_haml_test.rb
48
-
49
- At the moment, running the tests with Ruby 1.8.7 fails because of issues with
50
- the JSON library. Please use 1.9.2 until this is resolved.
51
-
52
- ### Lua ###
53
-
54
- The Lua test depends on
55
- [Penlight](http://stevedonovan.github.com/Penlight/),
56
- [Telescope](http://github.com/norman/telescope),
57
- [jason4lua](http://json.luaforge.net/), and
58
- [Lua Haml](http://github.com/norman/lua-haml). Install and run `tsc
59
- lua_haml_spec.lua`.
60
-
61
- ### Getting it ###
62
-
63
- You can access the [Git repository](http://github.com/norman/haml-spec) at:
64
-
65
- git://github.com/norman/haml-spec.git
66
-
67
- Patches are *very* welcome, as are test runners for your Haml implementation.
68
-
69
- As long as any test you add run against Ruby Haml and are not redundant, I'll
70
- be very happy to add them.
71
-
72
- ### Test JSON format ###
73
-
74
- "test name" : {
75
- "haml" : "haml input",
76
- "html" : "expected html output",
77
- "result" : "expected test result",
78
- "locals" : "local vars",
79
- "config" : "config params",
80
- "optional" : true|false
81
- }
82
-
83
- * test name: This should be a *very* brief description of what's being tested. It can
84
- be used by the test runners to name test methods, or to exclude certain tests from being
85
- run.
86
- * haml: The Haml code to be evaluated. Always required.
87
- * html: The HTML output that should be generated. Required unless "result" is "error".
88
- * result: Can be "pass" or "error". If it's absent, then "pass" is assumed. If it's "error",
89
- then the goal of the test is to make sure that malformed Haml code generates an error.
90
- * locals: An object containing local variables needed for the test.
91
- * config: An object containing configuration parameters used to run the test.
92
- The configuration parameters should be usable directly by Ruby's Haml with no
93
- modification. If your implementation uses config parameters with different
94
- names, you may need to process them to make them match your implementation.
95
- If your implementation has options that do not exist in Ruby's Haml, then you
96
- should add tests for this in your implementation's test rather than here.
97
- * optional: whether or not the test is optional
98
-
99
- ## License ##
100
-
101
- This project is released under the [WTFPL](http://sam.zoy.org/wtfpl/) in order
102
- to be as usable as possible in any project, commercial or free.
103
-
104
- ## Author ##
105
-
106
- [Norman Clarke](mailto:norman@njclarke.com)
@@ -1,38 +0,0 @@
1
- local dir = require 'pl.dir'
2
- local haml = require 'haml'
3
- local json = require 'json'
4
- local path = require 'pl.path'
5
- local telescope = require 'telescope'
6
- local assert = assert
7
- local describe = telescope.describe
8
- local getinfo = debug.getinfo
9
- local it = telescope.it
10
- local open = io.open
11
- local pairs = pairs
12
-
13
- module('hamlspec')
14
-
15
- local function get_tests(filename)
16
- local me = path.abspath(getinfo(1).source:match("@(.*)$"))
17
- return path.join(path.dirname(me), filename)
18
- end
19
-
20
- local json_file = get_tests("tests.json")
21
- local file = assert(open(json_file))
22
- local input = file:read '*a'
23
- file:close()
24
-
25
- local contexts = json.decode(input)
26
-
27
- describe("LuaHaml", function()
28
- for context, expectations in pairs(contexts) do
29
- describe("When handling " .. context, function()
30
- for name, exp in pairs(expectations) do
31
- it(("should correctly render %s"):format(name), function()
32
- local engine = haml.new(exp.config)
33
- assert_equal(engine:render(exp.haml, exp.locals), exp.html)
34
- end)
35
- end
36
- end)
37
- end
38
- end)
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env perl
2
-
3
- use strict;
4
- use warnings;
5
-
6
- use Test::More 'no_plan';
7
- use Text::Haml;
8
- use FindBin;
9
- use JSON 'from_json';
10
-
11
- our $VERSION = 0.990101;
12
-
13
- my $tests;
14
-
15
- open FILE, "< $FindBin::Bin/tests.json" or die $!;
16
- $tests = from_json(join("\n", <FILE>));
17
- close FILE;
18
-
19
- while (my ($section_name, $section) = each %$tests) {
20
- diag $section_name;
21
-
22
- while (my ($test_name, $test) = each %$section) {
23
- is( Text::Haml->new(%{$test->{config}}, vars_as_subs => 1)
24
- ->render($test->{haml}, %{$test->{locals}}),
25
- $test->{html}, $test_name
26
- );
27
- }
28
- }
29
- __END__
30
-
31
- =head1 NAME
32
-
33
- perl_haml_test.pl - Text::Haml spec tests runner
34
-
35
- =head1 SYNOPSIS
36
-
37
- $ perl perl_haml_test.pl
38
-
39
- # conditional comments
40
- ok 1 - a conditional comment
41
- # tags with nested content
42
- ok 2 - a tag with CSS
43
-
44
- ...
45
-
46
- ok 81 - an inline comment
47
- ok 82 - a nested comment
48
- 1..82
49
-
50
- =head1 DESCRIPTION
51
-
52
- This file is a part of Haml spec tests envorinment. It tests Perl
53
- implementation using <Text::Haml>.
54
-
55
- =head1 DEPENDENCIES
56
-
57
- =over
58
-
59
- * Text::Haml (available via CPAN or http://github.com/vti/text-haml)
60
- * JSON (available on CPAN)
61
- * Test::More (included in Perl core)
62
- * FindBin (included in Perl core)
63
-
64
- =back
65
-
66
- =head1 SEE ALSO
67
-
68
- L<Text::Haml>
69
-
70
- =head1 AUTHOR
71
-
72
- Viacheslav Tykhanovskyi, C<vti@cpan.org>.
73
-
74
- =head1 COPYRIGHT AND LICENSE
75
-
76
- Copyright (C) 2009, Viacheslav Tykhanovskyi
77
-
78
- This program is free software, you can redistribute it and/or modify it under
79
- the terms of the Artistic License version 2.0.
80
-
81
- =cut
@@ -1,23 +0,0 @@
1
- require "rubygems"
2
- require "minitest/autorun"
3
- require "json"
4
- require "haml"
5
-
6
- class HamlTest < MiniTest::Unit::TestCase
7
- contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json"))
8
- contexts.each do |context|
9
- context[1].each do |name, test|
10
- define_method("test_spec: #{name} (#{context[0]})") do
11
- html = test["html"]
12
- haml = test["haml"]
13
- locals = Hash[(test["locals"] || {}).map {|x, y| [x.to_sym, y]}]
14
- options = Hash[(test["config"] || {}).map {|x, y| [x.to_sym, y]}]
15
- options[:format] = options[:format].to_sym if options.key?(:format)
16
- engine = Haml::Engine.new(haml, options)
17
- result = engine.render(Object.new, locals)
18
-
19
- assert_equal html, result.strip
20
- end
21
- end
22
- end
23
- end