haml 3.1.7 → 3.1.8

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.

data/REVISION CHANGED
@@ -1 +1 @@
1
- d6eded7fcfce1ec5b72d73556ec0800ca599a1e3
1
+ c167370cafd8555106d8b35a7cc6d25a2f83ec7c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.7
1
+ 3.1.8
@@ -251,8 +251,9 @@ END
251
251
  def push_silent(text, can_suppress = false)
252
252
  flush_merged_text
253
253
  return if can_suppress && options[:suppress_eval]
254
- @precompiled << "#{resolve_newlines}#{text}\n"
255
- @output_line += text.count("\n") + 1
254
+ newline = (text == "end") ? ";" : "\n"
255
+ @precompiled << "#{resolve_newlines}#{text}#{newline}"
256
+ @output_line += (text + newline).count("\n")
256
257
  end
257
258
 
258
259
  # Adds `text` to `@buffer` with appropriate tabulation
@@ -87,6 +87,9 @@ MESSAGE
87
87
  "foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5],
88
88
  "= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
89
89
  "- case 1\n\n- when 1\n - raise 'foo'" => ["foo", 4],
90
+ "- tap do\n - tap do\n text\n- raise 'foo'" => ["foo", 4],
91
+ "- tap do\n - tap do\n text\n - raise 'foo'" => ["foo", 4],
92
+ "- tap do\n - tap do\n text\n text\n- raise 'foo'" => ["foo", 5],
90
93
  }
91
94
 
92
95
  User = Struct.new('User', :id)
@@ -1212,17 +1215,20 @@ HAML
1212
1215
  assert_equal(expected_message, err.message, "Line: #{key}")
1213
1216
  end
1214
1217
 
1215
- if Haml::Util.ruby1_8?
1216
- # Sometimes, the first backtrace entry is *only* in the message.
1217
- # No idea why.
1218
- bt =
1219
- if expected_message == :compile && err.message.include?("\n")
1220
- err.message.split("\n", 2)[1]
1221
- else
1222
- err.backtrace[0]
1223
- end
1224
- assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, bt, "Line: #{key}")
1218
+ if expected_message == :compile && err.message.include?("\n")
1219
+ if Haml::Util.ruby1_8?
1220
+ # Sometimes, the first backtrace entry is *only* in the message.
1221
+ # No idea why.
1222
+ bt = err.message.split("\n", 2)[1]
1223
+ else
1224
+ bt = err.message.split("\n", 2)[0]
1225
+ end
1226
+ else
1227
+ bt = err.backtrace[0]
1225
1228
  end
1229
+
1230
+ source_location = bt.split(":", 3).first(2).join(":")
1231
+ assert_equal("#{__FILE__}:#{line_no}", source_location, "Line: #{key}")
1226
1232
  else
1227
1233
  assert(false, "Exception not raised for\n#{key}")
1228
1234
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.7
5
4
  prerelease:
5
+ version: 3.1.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-12 00:00:00.000000000 Z
14
+ date: 2013-02-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: yard
@@ -21,14 +21,14 @@ dependencies:
21
21
  - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.5.3
24
- type: :development
25
- prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
25
  none: false
28
26
  requirements:
29
27
  - - ! '>='
30
28
  - !ruby/object:Gem::Version
31
29
  version: 0.5.3
30
+ prerelease: false
31
+ type: :development
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: maruku
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -37,14 +37,14 @@ dependencies:
37
37
  - - ! '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: 0.5.9
40
- type: :development
41
- prerelease: false
42
40
  version_requirements: !ruby/object:Gem::Requirement
43
41
  none: false
44
42
  requirements:
45
43
  - - ! '>='
46
44
  - !ruby/object:Gem::Version
47
45
  version: 0.5.9
46
+ prerelease: false
47
+ type: :development
48
48
  description: ! " Haml (HTML Abstraction Markup Language) is a layer on top of
49
49
  XHTML or XML\n that's designed to express the structure of XHTML or XML documents\n
50
50
  \ in a non-repetitive, elegant, easy way,\n using indentation rather than
@@ -174,12 +174,6 @@ files:
174
174
  - test/haml/templates/very_basic.haml
175
175
  - test/haml/templates/whitespace_handling.haml
176
176
  - test/haml/util_test.rb
177
- - test/haml-spec/LICENSE
178
- - test/haml-spec/lua_haml_spec.lua
179
- - test/haml-spec/perl_haml_test.pl
180
- - test/haml-spec/README.md
181
- - test/haml-spec/ruby_haml_test.rb
182
- - test/haml-spec/tests.json
183
177
  - test/linked_rails.rb
184
178
  - test/test_helper.rb
185
179
  - extra/update_watch.rb
@@ -482,4 +476,3 @@ test_files:
482
476
  - test/haml/spec_test.rb
483
477
  - test/haml/template_test.rb
484
478
  - test/haml/util_test.rb
485
- - test/haml-spec/ruby_haml_test.rb
@@ -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
@@ -1,660 +0,0 @@
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
- }