haml 4.0.6 → 4.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b001616cbcf722d8dd8f3e4a99d7895d1ce34b
4
- data.tar.gz: b87d0bfe9067818b38abf03b6c0d3128cb9f4fb6
3
+ metadata.gz: b7a38de787ab9e47ac3221b040c9c38ecf4884df
4
+ data.tar.gz: 29497caf8377f40940a0e094d1477ea2403f380f
5
5
  SHA512:
6
- metadata.gz: a0872b7e36195c11d167e066ab51c8006d9c4f50130caa2947f058897c57b2960d619ecee6379782fbbd1a4c908d588c3895ad5a4a24bf5ba90f216272005b14
7
- data.tar.gz: 2271653d27a61a75e130fed6dad51e02ebed14e61123448731c910b21e679fc8bb64d3fa5ea55604a1354c7b66dd907ba5e03a8fe6c53dcb484fb79ab1a607b6
6
+ metadata.gz: 3c71810f7359be3c7536eea848acefb06d09859443d6b80a31908ea07b6c109dc082a7ad8a7e95f1305b08aefeabbe46dd48cc186dff66eb4fe46bdd258956e1
7
+ data.tar.gz: 0d85d5e2164cef71dab787d7967ab4a3e7ecd1dd0b5e212188032bd94faa6d4923cdb39cd5fdffcdaed6da13b6f637d1d5d5c8171ca878fa017ac64c345d589f
@@ -1,5 +1,12 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 4.0.7
4
+
5
+ Released on August 10, 2015
6
+ ([diff](https://github.com/haml/haml/compare/4.0.6...4.0.7)).
7
+
8
+ * Significantly improve performance of regexp used to fix whitespace handling in textareas (thanks [Stan Hu](https://github.com/stanhu)).
9
+
3
10
  ## 4.0.6
4
11
 
5
12
  Released on Dec 1, 2014 ([diff](https://github.com/haml/haml/compare/4.0.5...4.0.6)).
@@ -329,7 +329,7 @@ This is compiled to:
329
329
  </html>
330
330
 
331
331
  You can use as many such attribute methods as you want by separating them with
332
- commas, like a Ruby argument list. All the hashes will me merged together, from
332
+ commas, like a Ruby argument list. All the hashes will be merged together, from
333
333
  left to right. For example, if you defined
334
334
 
335
335
  def hash1
@@ -270,16 +270,16 @@ RUBY
270
270
  # @since Haml 4.0.1
271
271
  # @private
272
272
  def fix_textareas!(input)
273
- pattern = /([ ]*)<(textarea)([^>]*)>(\n|&#x000A;)(.*?)(<\/\2>)/im
273
+ pattern = /<(textarea)([^>]*)>(\n|&#x000A;)(.*?)<\/textarea>/im
274
274
  input.gsub!(pattern) do |s|
275
275
  match = pattern.match(s)
276
- content = match[5]
277
- if match[4] == '&#x000A;'
276
+ content = match[4]
277
+ if match[3] == '&#x000A;'
278
278
  content.sub!(/\A /, '&#x0020;')
279
279
  else
280
280
  content.sub!(/\A[ ]*/, '')
281
281
  end
282
- "#{match[1]}<#{match[2]}#{match[3]}>\n#{content}</#{match[2]}>"
282
+ "<#{match[1]}#{match[2]}>\n#{content}</#{match[1]}>"
283
283
  end
284
284
  end
285
285
 
@@ -1,3 +1,3 @@
1
1
  module Haml
2
- VERSION = "4.0.6"
2
+ VERSION = '4.0.7'
3
3
  end
@@ -0,0 +1,14 @@
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
+
@@ -0,0 +1,106 @@
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)
@@ -0,0 +1,38 @@
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)
@@ -0,0 +1,81 @@
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
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,660 @@
1
+ {
2
+ "headers" : {
3
+
4
+ "an XHTML XML prolog" : {
5
+ "haml" : "!!! XML",
6
+ "html" : "<?xml version='1.0' encoding='utf-8' ?>",
7
+ "config" : {
8
+ "format" : "xhtml"
9
+ }
10
+ },
11
+
12
+ "an XHTML default (transitional) doctype" : {
13
+ "haml" : "!!!",
14
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
15
+ "config" : {
16
+ "format" : "xhtml"
17
+ }
18
+ },
19
+
20
+ "an XHTML 1.1 doctype" : {
21
+ "haml" : "!!! 1.1",
22
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
23
+ "config" : {
24
+ "format" : "xhtml"
25
+ }
26
+ },
27
+
28
+ "an XHTML 1.2 mobile doctype" : {
29
+ "haml" : "!!! mobile",
30
+ "html" : "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">",
31
+ "config" : {
32
+ "format" : "xhtml"
33
+ }
34
+ },
35
+
36
+ "an XHTML 1.1 basic doctype" : {
37
+ "haml" : "!!! basic",
38
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">",
39
+ "config" : {
40
+ "format" : "xhtml"
41
+ }
42
+ },
43
+
44
+ "an XHTML 1.0 frameset doctype" : {
45
+ "haml" : "!!! frameset",
46
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">",
47
+ "config" : {
48
+ "format" : "xhtml"
49
+ }
50
+ },
51
+
52
+ "an HTML 5 doctype with XHTML syntax" : {
53
+ "haml" : "!!! 5",
54
+ "html" : "<!DOCTYPE html>",
55
+ "config" : {
56
+ "format" : "xhtml"
57
+ }
58
+ },
59
+
60
+ "an HTML 5 XML prolog (silent)" : {
61
+ "haml" : "!!! XML",
62
+ "html" : "",
63
+ "config" : {
64
+ "format" : "html5"
65
+ }
66
+ },
67
+
68
+ "an HTML 5 doctype" : {
69
+ "haml" : "!!!",
70
+ "html" : "<!DOCTYPE html>",
71
+ "config" : {
72
+ "format" : "html5"
73
+ }
74
+ },
75
+
76
+ "an HTML 4 XML prolog (silent)" : {
77
+ "haml" : "!!! XML",
78
+ "html" : "",
79
+ "config" : {
80
+ "format" : "html4"
81
+ }
82
+ },
83
+
84
+ "an HTML 4 default (transitional) doctype" : {
85
+ "haml" : "!!!",
86
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
87
+ "config" : {
88
+ "format" : "html4"
89
+ }
90
+ },
91
+
92
+ "an HTML 4 frameset doctype" : {
93
+ "haml" : "!!! frameset",
94
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
95
+ "config" : {
96
+ "format" : "html4"
97
+ }
98
+ },
99
+
100
+ "an HTML 4 strict doctype" : {
101
+ "haml" : "!!! strict",
102
+ "html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
103
+ "config" : {
104
+ "format" : "html4"
105
+ }
106
+ }
107
+
108
+ },
109
+
110
+ "basic Haml tags and CSS": {
111
+
112
+ "a simple Haml tag" : {
113
+ "haml" : "%p",
114
+ "html" : "<p></p>"
115
+ },
116
+
117
+ "a self-closing tag (XHTML)" : {
118
+ "haml" : "%meta",
119
+ "html" : "<meta />",
120
+ "config" : {
121
+ "format" : "xhtml"
122
+ }
123
+ },
124
+
125
+ "a self-closing tag (HTML4)" : {
126
+ "haml" : "%meta",
127
+ "html" : "<meta>",
128
+ "config" : {
129
+ "format" : "html4"
130
+ }
131
+ },
132
+
133
+ "a self-closing tag (HTML5)" : {
134
+ "haml" : "%meta",
135
+ "html" : "<meta>",
136
+ "config" : {
137
+ "format" : "html5"
138
+ }
139
+ },
140
+
141
+ "a self-closing tag ('/' modifier + XHTML)" : {
142
+ "haml" : "%zzz/",
143
+ "html" : "<zzz />",
144
+ "config" : {
145
+ "format" : "xhtml"
146
+ }
147
+ },
148
+
149
+ "a self-closing tag ('/' modifier + HTML5)" : {
150
+ "haml" : "%zzz/",
151
+ "html" : "<zzz>",
152
+ "config" : {
153
+ "format" : "html5"
154
+ }
155
+ },
156
+
157
+ "a tag with a CSS class" : {
158
+ "haml" : "%p.class1",
159
+ "html" : "<p class='class1'></p>"
160
+ },
161
+
162
+ "a tag with multiple CSS classes" : {
163
+ "haml" : "%p.class1.class2",
164
+ "html" : "<p class='class1 class2'></p>"
165
+ },
166
+
167
+ "a tag with a CSS id" : {
168
+ "haml" : "%p#id1",
169
+ "html" : "<p id='id1'></p>"
170
+ },
171
+
172
+ "a tag with multiple CSS id's" : {
173
+ "haml" : "%p#id1#id2",
174
+ "html" : "<p id='id2'></p>"
175
+ },
176
+
177
+ "a tag with a class followed by an id" : {
178
+ "haml" : "%p.class1#id1",
179
+ "html" : "<p class='class1' id='id1'></p>"
180
+ },
181
+
182
+ "a tag with an id followed by a class" : {
183
+ "haml" : "%p#id1.class1",
184
+ "html" : "<p class='class1' id='id1'></p>"
185
+ },
186
+
187
+ "an implicit div with a CSS id" : {
188
+ "haml" : "#id1",
189
+ "html" : "<div id='id1'></div>"
190
+ },
191
+
192
+ "an implicit div with a CSS class" : {
193
+ "haml" : ".class1",
194
+ "html" : "<div class='class1'></div>"
195
+ },
196
+
197
+ "multiple simple Haml tags" : {
198
+ "haml" : "%div\n %div\n %p",
199
+ "html" : "<div>\n <div>\n <p></p>\n </div>\n</div>"
200
+ }
201
+ },
202
+
203
+ "tags with unusual HTML characters" : {
204
+
205
+ "a tag with colons" : {
206
+ "haml" : "%ns:tag",
207
+ "html" : "<ns:tag></ns:tag>"
208
+ },
209
+
210
+ "a tag with underscores" : {
211
+ "haml" : "%snake_case",
212
+ "html" : "<snake_case></snake_case>"
213
+ },
214
+
215
+ "a tag with dashes" : {
216
+ "haml" : "%dashed-tag",
217
+ "html" : "<dashed-tag></dashed-tag>"
218
+ },
219
+
220
+ "a tag with camelCase" : {
221
+ "haml" : "%camelCase",
222
+ "html" : "<camelCase></camelCase>"
223
+ },
224
+
225
+ "a tag with PascalCase" : {
226
+ "haml" : "%PascalCase",
227
+ "html" : "<PascalCase></PascalCase>"
228
+ }
229
+ },
230
+
231
+ "tags with unusual CSS identifiers" : {
232
+
233
+ "an all-numeric class" : {
234
+ "haml" : ".123",
235
+ "html" : "<div class='123'></div>"
236
+ },
237
+
238
+ "a class with underscores" : {
239
+ "haml" : ".__",
240
+ "html" : "<div class='__'></div>"
241
+ },
242
+
243
+ "a class with dashes" : {
244
+ "haml" : ".--",
245
+ "html" : "<div class='--'></div>"
246
+ }
247
+ },
248
+
249
+ "tags with inline content" : {
250
+
251
+ "Inline content simple tag" : {
252
+ "haml" : "%p hello",
253
+ "html" : "<p>hello</p>"
254
+ },
255
+
256
+ "Inline content tag with CSS" : {
257
+ "haml" : "%p.class1 hello",
258
+ "html" : "<p class='class1'>hello</p>"
259
+ },
260
+
261
+ "Inline content multiple simple tags" : {
262
+ "haml" : "%div\n %div\n %p text",
263
+ "html" : "<div>\n <div>\n <p>text</p>\n </div>\n</div>"
264
+ }
265
+ },
266
+
267
+ "tags with nested content" : {
268
+
269
+ "Nested content simple tag" : {
270
+ "haml" : "%p\n hello",
271
+ "html" : "<p>\n hello\n</p>"
272
+ },
273
+
274
+ "Nested content tag with CSS" : {
275
+ "haml" : "%p.class1\n hello",
276
+ "html" : "<p class='class1'>\n hello\n</p>"
277
+ },
278
+
279
+ "Nested content multiple simple tags" : {
280
+ "haml" : "%div\n %div\n %p\n text",
281
+ "html" : "<div>\n <div>\n <p>\n text\n </p>\n </div>\n</div>"
282
+ }
283
+ },
284
+
285
+ "tags with HTML-style attributes": {
286
+
287
+ "HTML-style one attribute" : {
288
+ "haml" : "%p(a='b')",
289
+ "html" : "<p a='b'></p>"
290
+ },
291
+
292
+ "HTML-style multiple attributes" : {
293
+ "haml" : "%p(a='b' c='d')",
294
+ "html" : "<p a='b' c='d'></p>"
295
+ },
296
+
297
+ "HTML-style attributes separated with newlines" : {
298
+ "haml" : "%p(a='b'\n c='d')",
299
+ "html" : "<p a='b' c='d'></p>"
300
+ },
301
+
302
+ "HTML-style interpolated attribute" : {
303
+ "haml" : "%p(a=\"#{var}\")",
304
+ "html" : "<p a='value'></p>",
305
+ "locals" : {
306
+ "var" : "value"
307
+ }
308
+ },
309
+
310
+ "HTML-style 'class' as an attribute" : {
311
+ "haml" : "%p(class='class1')",
312
+ "html" : "<p class='class1'></p>"
313
+ },
314
+
315
+ "HTML-style tag with a CSS class and 'class' as an attribute" : {
316
+ "haml" : "%p.class2(class='class1')",
317
+ "html" : "<p class='class1 class2'></p>"
318
+ },
319
+
320
+ "HTML-style tag with 'id' as an attribute" : {
321
+ "haml" : "%p(id='1')",
322
+ "html" : "<p id='1'></p>"
323
+ },
324
+
325
+ "HTML-style tag with a CSS id and 'id' as an attribute" : {
326
+ "haml" : "%p#id(id='1')",
327
+ "html" : "<p id='id_1'></p>"
328
+ },
329
+
330
+ "HTML-style tag with a variable attribute" : {
331
+ "haml" : "%p(class=var)",
332
+ "html" : "<p class='hello'></p>",
333
+ "locals" : {
334
+ "var" : "hello"
335
+ }
336
+ },
337
+
338
+ "HTML-style tag with a CSS class and 'class' as a variable attribute" : {
339
+ "haml" : ".hello(class=var)",
340
+ "html" : "<div class='hello world'></div>",
341
+ "locals" : {
342
+ "var" : "world"
343
+ }
344
+ },
345
+
346
+ "HTML-style tag multiple CSS classes (sorted correctly)" : {
347
+ "haml" : ".z(class=var)",
348
+ "html" : "<div class='a z'></div>",
349
+ "locals" : {
350
+ "var" : "a"
351
+ }
352
+ }
353
+ },
354
+
355
+ "tags with Ruby-style attributes": {
356
+
357
+ "Ruby-style one attribute" : {
358
+ "haml" : "%p{:a => 'b'}",
359
+ "html" : "<p a='b'></p>",
360
+ "optional" : true
361
+ },
362
+
363
+ "Ruby-style attributes hash with whitespace" : {
364
+ "haml" : "%p{ :a => 'b' }",
365
+ "html" : "<p a='b'></p>",
366
+ "optional" : true
367
+ },
368
+
369
+ "Ruby-style interpolated attribute" : {
370
+ "haml" : "%p{:a =>\"#{var}\"}",
371
+ "html" : "<p a='value'></p>",
372
+ "optional" : true,
373
+ "locals" : {
374
+ "var" : "value"
375
+ }
376
+ },
377
+
378
+ "Ruby-style multiple attributes" : {
379
+ "haml" : "%p{ :a => 'b', 'c' => 'd' }",
380
+ "html" : "<p a='b' c='d'></p>",
381
+ "optional" : true
382
+ },
383
+
384
+ "Ruby-style attributes separated with newlines" : {
385
+ "haml" : "%p{ :a => 'b',\n 'c' => 'd' }",
386
+ "html" : "<p a='b' c='d'></p>",
387
+ "optional" : true
388
+ },
389
+
390
+ "Ruby-style 'class' as an attribute" : {
391
+ "haml" : "%p{:class => 'class1'}",
392
+ "html" : "<p class='class1'></p>",
393
+ "optional" : true
394
+ },
395
+
396
+ "Ruby-style tag with a CSS class and 'class' as an attribute" : {
397
+ "haml" : "%p.class2{:class => 'class1'}",
398
+ "html" : "<p class='class1 class2'></p>",
399
+ "optional" : true
400
+ },
401
+
402
+ "Ruby-style tag with 'id' as an attribute" : {
403
+ "haml" : "%p{:id => '1'}",
404
+ "html" : "<p id='1'></p>",
405
+ "optional" : true
406
+ },
407
+
408
+ "Ruby-style tag with a CSS id and 'id' as an attribute" : {
409
+ "haml" : "%p#id{:id => '1'}",
410
+ "html" : "<p id='id_1'></p>",
411
+ "optional" : true
412
+ },
413
+
414
+ "Ruby-style tag with a CSS id and a numeric 'id' as an attribute" : {
415
+ "haml" : "%p#id{:id => 1}",
416
+ "html" : "<p id='id_1'></p>",
417
+ "optional" : true
418
+ },
419
+
420
+ "Ruby-style tag with a variable attribute" : {
421
+ "haml" : "%p{:class => var}",
422
+ "html" : "<p class='hello'></p>",
423
+ "optional" : true,
424
+ "locals" : {
425
+ "var" : "hello"
426
+ }
427
+ },
428
+
429
+ "Ruby-style tag with a CSS class and 'class' as a variable attribute" : {
430
+ "haml" : ".hello{:class => var}",
431
+ "html" : "<div class='hello world'></div>",
432
+ "optional" : true,
433
+ "locals" : {
434
+ "var" : "world"
435
+ }
436
+ },
437
+
438
+ "Ruby-style tag multiple CSS classes (sorted correctly)" : {
439
+ "haml" : ".z{:class => var}",
440
+ "html" : "<div class='a z'></div>",
441
+ "optional" : true,
442
+ "locals" : {
443
+ "var" : "a"
444
+ }
445
+ }
446
+ },
447
+
448
+ "silent comments" : {
449
+
450
+ "an inline silent comment" : {
451
+ "haml" : "-# hello",
452
+ "html" : ""
453
+ },
454
+
455
+ "a nested silent comment" : {
456
+ "haml" : "-#\n hello",
457
+ "html" : ""
458
+ },
459
+
460
+ "a multiply nested silent comment" : {
461
+ "haml" : "-#\n %div\n foo",
462
+ "html" : ""
463
+ },
464
+
465
+ "a multiply nested silent comment with inconsistent indents" : {
466
+ "haml" : "-#\n %div\n foo",
467
+ "html" : ""
468
+ }
469
+ },
470
+
471
+ "markup comments" : {
472
+
473
+ "an inline markup comment" : {
474
+ "haml" : "/ comment",
475
+ "html" : "<!-- comment -->"
476
+ },
477
+
478
+ "a nested markup comment" : {
479
+ "haml" : "/\n comment\n comment2",
480
+ "html" : "<!--\n comment\n comment2\n-->"
481
+ }
482
+ },
483
+
484
+ "conditional comments": {
485
+ "a conditional comment" : {
486
+ "haml" : "/[if IE]\n %p a",
487
+ "html" : "<!--[if IE]>\n <p>a</p>\n<![endif]-->"
488
+ }
489
+ },
490
+
491
+ "internal filters": {
492
+
493
+ "content in an 'escaped' filter" : {
494
+ "haml" : ":escaped\n <&\">",
495
+ "html" : "&lt;&amp;&quot;&gt;"
496
+ },
497
+
498
+ "content in a 'preserve' filter" : {
499
+ "haml" : ":preserve\n hello\n\n%p",
500
+ "html" : "hello&#x000A;\n<p></p>"
501
+ },
502
+
503
+ "content in a 'plain' filter" : {
504
+ "haml" : ":plain\n hello\n\n%p",
505
+ "html" : "hello\n<p></p>"
506
+ },
507
+
508
+ "content in a 'css' filter (XHTML)" : {
509
+ "haml" : ":css\n hello\n\n%p",
510
+ "html" : "<style type='text/css'>\n /*<![CDATA[*/\n hello\n /*]]>*/\n</style>\n<p></p>",
511
+ "config" : {
512
+ "format" : "xhtml"
513
+ }
514
+ },
515
+
516
+ "content in a 'javascript' filter (XHTML)" : {
517
+ "haml" : ":javascript\n a();\n%p",
518
+ "html" : "<script type='text/javascript'>\n //<![CDATA[\n a();\n //]]>\n</script>\n<p></p>",
519
+ "config" : {
520
+ "format" : "xhtml"
521
+ }
522
+ },
523
+
524
+ "content in a 'css' filter (HTML)" : {
525
+ "haml" : ":css\n hello\n\n%p",
526
+ "html" : "<style>\n hello\n</style>\n<p></p>",
527
+ "config" : {
528
+ "format" : "html5"
529
+ }
530
+ },
531
+
532
+ "content in a 'javascript' filter (HTML)" : {
533
+ "haml" : ":javascript\n a();\n%p",
534
+ "html" : "<script>\n a();\n</script>\n<p></p>",
535
+ "config" : {
536
+ "format" : "html5"
537
+ }
538
+ }
539
+ },
540
+
541
+ "Ruby-style interpolation": {
542
+
543
+ "interpolation inside inline content" : {
544
+ "haml" : "%p #{var}",
545
+ "html" : "<p>value</p>",
546
+ "optional" : true,
547
+ "locals" : {
548
+ "var" : "value"
549
+ }
550
+ },
551
+
552
+ "no interpolation when escaped" : {
553
+ "haml" : "%p \\#{var}",
554
+ "html" : "<p>#{var}</p>",
555
+ "optional" : true,
556
+ "locals" : {
557
+ "var" : "value"
558
+ }
559
+ },
560
+
561
+ "interpolation when the escape character is escaped" : {
562
+ "haml" : "%p \\\\#{var}",
563
+ "html" : "<p>\\value</p>",
564
+ "optional" : true,
565
+ "locals" : {
566
+ "var" : "value"
567
+ }
568
+ },
569
+
570
+ "interpolation inside filtered content" : {
571
+ "haml" : ":plain\n #{var} interpolated: #{var}",
572
+ "html" : "value interpolated: value",
573
+ "optional" : true,
574
+ "locals" : {
575
+ "var" : "value"
576
+ }
577
+ }
578
+ },
579
+
580
+ "HTML escaping" : {
581
+
582
+ "code following '&='" : {
583
+ "haml" : "&= '<\"&>'",
584
+ "html" : "&lt;&quot;&amp;&gt;"
585
+ },
586
+
587
+ "code following '=' when escape_haml is set to true" : {
588
+ "haml" : "= '<\"&>'",
589
+ "html" : "&lt;&quot;&amp;&gt;",
590
+ "config" : {
591
+ "escape_html" : "true"
592
+ }
593
+ },
594
+
595
+ "code following '!=' when escape_haml is set to true" : {
596
+ "haml" : "!= '<\"&>'",
597
+ "html" : "<\"&>",
598
+ "config" : {
599
+ "escape_html" : "true"
600
+ }
601
+ }
602
+
603
+ },
604
+
605
+ "boolean attributes" : {
606
+
607
+ "boolean attribute with XHTML" : {
608
+ "haml" : "%input(checked=true)",
609
+ "html" : "<input checked='checked' />",
610
+ "config" : {
611
+ "format" : "xhtml"
612
+ }
613
+ },
614
+
615
+ "boolean attribute with HTML" : {
616
+ "haml" : "%input(checked=true)",
617
+ "html" : "<input checked>",
618
+ "config" : {
619
+ "format" : "html5"
620
+ }
621
+ }
622
+ },
623
+
624
+ "whitespace preservation" : {
625
+
626
+ "following the '~' operator" : {
627
+ "haml" : "~ \"Foo\\n<pre>Bar\\nBaz</pre>\"",
628
+ "html" : "Foo\n<pre>Bar&#x000A;Baz</pre>",
629
+ "optional" : true
630
+ },
631
+
632
+ "inside a textarea tag" : {
633
+ "haml" : "%textarea\n hello\n hello",
634
+ "html" : "<textarea>hello\nhello</textarea>"
635
+ },
636
+
637
+ "inside a pre tag" : {
638
+ "haml" : "%pre\n hello\n hello",
639
+ "html" : "<pre>hello\nhello</pre>"
640
+ }
641
+ },
642
+
643
+ "whitespace removal" : {
644
+
645
+ "a tag with '>' appended and inline content" : {
646
+ "haml" : "%li hello\n%li> world\n%li again",
647
+ "html" : "<li>hello</li><li>world</li><li>again</li>"
648
+ },
649
+
650
+ "a tag with '>' appended and nested content" : {
651
+ "haml" : "%li hello\n%li>\n world\n%li again",
652
+ "html" : "<li>hello</li><li>\n world\n</li><li>again</li>"
653
+ },
654
+
655
+ "a tag with '<' appended" : {
656
+ "haml" : "%p<\n hello\n world",
657
+ "html" : "<p>hello\nworld</p>"
658
+ }
659
+ }
660
+ }
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.6
4
+ version: 4.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-01 00:00:00.000000000 Z
13
+ date: 2015-08-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: tilt
@@ -136,6 +136,12 @@ files:
136
136
  - test/gemfiles/Gemfile.rails-3.1.x
137
137
  - test/gemfiles/Gemfile.rails-3.2.x
138
138
  - 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
139
145
  - test/helper_test.rb
140
146
  - test/markaby/standard.mab
141
147
  - test/mocks/article.rb
@@ -228,13 +234,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
234
  version: '0'
229
235
  requirements: []
230
236
  rubyforge_project:
231
- rubygems_version: 2.4.4
237
+ rubygems_version: 2.4.7
232
238
  signing_key:
233
239
  specification_version: 4
234
240
  summary: An elegant, structured (X)HTML/XML templating engine.
235
241
  test_files:
236
242
  - test/engine_test.rb
237
243
  - test/filters_test.rb
244
+ - test/haml-spec/ruby_haml_test.rb
238
245
  - test/helper_test.rb
239
246
  - test/parser_test.rb
240
247
  - test/template_test.rb