haml 3.2.0.rc.1 → 3.2.0.rc.2

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/FAQ.md CHANGED
@@ -151,7 +151,7 @@ For other plugins, a little searching will probably turn up a way to fix them as
151
151
 
152
152
  ## You still haven't answered my question!
153
153
 
154
- Sorry! Try looking at the [Haml](http://haml.info/docs/yardoc/HAML_REFERENCE.md.html) reference,
154
+ Sorry! Try looking at the [Haml](http://haml.info/docs/yardoc/file.REFERENCE.html) reference,
155
155
  If you can't find an answer there,
156
156
  feel free to ask in `#haml` on irc.freenode.net
157
157
  or send an email to the [mailing list](http://groups.google.com/group/haml).
@@ -343,7 +343,7 @@ left to right. For example, if you defined
343
343
 
344
344
  then
345
345
 
346
- %sandwich{hash1, hash2, :delicious => true}/
346
+ %sandwich{hash1, hash2, :delicious => 'true'}/
347
347
 
348
348
  would compile to:
349
349
 
@@ -125,8 +125,11 @@ module Haml
125
125
  extend Haml::Helpers
126
126
  @haml_buffer = buffer
127
127
  end
128
-
129
- eval(@compiler.precompiled_with_return_value, scope, @options[:filename], @options[:line])
128
+ begin
129
+ eval(@compiler.precompiled_with_return_value, scope, @options[:filename], @options[:line])
130
+ rescue ::SyntaxError => e
131
+ raise SyntaxError, e.message
132
+ end
130
133
  ensure
131
134
  # Get rid of the current buffer
132
135
  scope_object.instance_eval do
@@ -167,8 +170,12 @@ module Haml
167
170
  scope = scope_object.instance_eval{binding}
168
171
  end
169
172
 
170
- eval("Proc.new { |*_haml_locals| _haml_locals = _haml_locals[0] || {};" +
171
- compiler.precompiled_with_ambles(local_names) + "}\n", scope, @options[:filename], @options[:line])
173
+ begin
174
+ eval("Proc.new { |*_haml_locals| _haml_locals = _haml_locals[0] || {};" +
175
+ compiler.precompiled_with_ambles(local_names) + "}\n", scope, @options[:filename], @options[:line])
176
+ rescue ::SyntaxError => e
177
+ raise SyntaxError, e.message
178
+ end
172
179
  end
173
180
 
174
181
  # Defines a method on `object` with the given name
@@ -241,7 +241,12 @@ END
241
241
  'Always add CDATA sections to javascript and css blocks.') do
242
242
  @options[:for_engine][:cdata] = true
243
243
  end
244
-
244
+
245
+ opts.on('--autoclose LIST',
246
+ 'Comma separated list of elements to be automatically self-closed.') do |list|
247
+ @options[:for_engine][:autoclose] = list.split(',')
248
+ end
249
+
245
250
  opts.on('--suppress-eval',
246
251
  'Don\'t evaluate Ruby scripts.') do
247
252
  @options[:for_engine][:suppress_eval] = true
@@ -312,7 +317,7 @@ END
312
317
  case e
313
318
  when ::Haml::SyntaxError; raise "Syntax error on line #{get_line e}: #{e.message}"
314
319
  when ::Haml::Error; raise "Haml error on line #{get_line e}: #{e.message}"
315
- else raise "Exception on line #{get_line e}: #{e.message}\n Use --trace for backtrace."
320
+ else raise "Exception on line #{get_line e}: #{e.message}"
316
321
  end
317
322
  end
318
323
 
@@ -314,14 +314,18 @@ RUBY
314
314
 
315
315
  def self.extended(base)
316
316
  base.options = {}
317
- base.instance_eval do
317
+ # There's a bug in 1.9.2 where the same parse tree cannot be shared
318
+ # across several singleton classes -- this bug is fixed in 1.9.3.
319
+ # We work around this by using a string eval instead of a block eval
320
+ # so that a new parse tree is created for each singleton class.
321
+ base.instance_eval %Q{
318
322
  include Base
319
323
 
320
324
  def render_with_options(text, compiler_options)
321
325
  text = template_class.new(nil, 1, options) {text}.render
322
326
  super(text, compiler_options)
323
327
  end
324
- end
328
+ }
325
329
  end
326
330
  end
327
331
 
@@ -108,9 +108,8 @@ module Haml
108
108
  # are `:html4` and `:xhtml`. If the output is set to XHTML, then Haml
109
109
  # automatically generates self-closing tags and wraps the output of the
110
110
  # Javascript and CSS-like filters inside CDATA. When the output is set to
111
- # :html5 or :html4, XML prologs are ignored. In all cases, an appropriate
112
- # doctype is generated from '!!!'.
113
- #
111
+ # `:html5` or `:html4`, XML prologs are ignored. In all cases, an appropriate
112
+ # doctype is generated from `!!!`.
114
113
  #
115
114
  # If the mime_type of the template being rendered is `text/xml` then a
116
115
  # format of `:xhtml` will be used even if the global output format is set to
@@ -8,7 +8,7 @@ module Haml
8
8
  # the ERB handler does.
9
9
 
10
10
  # In Rails 3.1+, we don't need to include Compilable.
11
- if ActionPack::VERSION::MAJOR < 3 || (ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 1)
11
+ if (ActionPack::VERSION::MAJOR == 3) && (ActionPack::VERSION::MINOR < 1)
12
12
  include ActionView::Template::Handlers::Compilable
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ module Haml
16
16
 
17
17
  def compile(template)
18
18
  options = Haml::Template.options.dup
19
- if template.respond_to? :type
19
+ if (ActionPack::VERSION::MAJOR >= 4) && template.respond_to?(:type)
20
20
  options[:mime_type] = template.type
21
21
  elsif template.respond_to? :mime_type
22
22
  options[:mime_type] = template.mime_type
@@ -1,3 +1,3 @@
1
1
  module Haml
2
- VERSION = "3.2.0.rc.1"
2
+ VERSION = "3.2.0.rc.2"
3
3
  end
@@ -1316,6 +1316,18 @@ HAML
1316
1316
  assert_nil(scope.send(:haml_buffer))
1317
1317
  end
1318
1318
 
1319
+ def test_render_proc_should_raise_haml_syntax_error_not_ruby_syntax_error
1320
+ assert_raises(Haml::SyntaxError) do
1321
+ Haml::Engine.new("%p{:foo => !}").render_proc(Object.new, :foo).call
1322
+ end
1323
+ end
1324
+
1325
+ def test_render_should_raise_haml_syntax_error_not_ruby_syntax_error
1326
+ assert_raises(Haml::SyntaxError) do
1327
+ Haml::Engine.new("%p{:foo => !}").render
1328
+ end
1329
+ end
1330
+
1319
1331
  def test_ugly_true
1320
1332
  assert_equal("<div id='outer'>\n<div id='inner'>\n<p>hello world</p>\n</div>\n</div>\n",
1321
1333
  render("#outer\n #inner\n %p hello world", :ugly => true))
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: 3.2.0.rc.1
4
+ version: 3.2.0.rc.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-10-09 00:00:00.000000000 Z
14
+ date: 2012-12-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: tilt
@@ -145,13 +145,6 @@ files:
145
145
  - test/gemfiles/Gemfile.rails-3.1.x
146
146
  - test/gemfiles/Gemfile.rails-3.2.x
147
147
  - test/gemfiles/Gemfile.rails-master
148
- - test/gemfiles/Gemfile.rails-master.lock
149
- - test/haml-spec/LICENSE
150
- - test/haml-spec/lua_haml_spec.lua
151
- - test/haml-spec/perl_haml_test.pl
152
- - test/haml-spec/README.md
153
- - test/haml-spec/ruby_haml_test.rb
154
- - test/haml-spec/tests.json
155
148
  - test/helper_test.rb
156
149
  - test/markaby/standard.mab
157
150
  - test/mocks/article.rb
@@ -268,7 +261,6 @@ summary: An elegant, structured (X)HTML/XML templating engine.
268
261
  test_files:
269
262
  - test/engine_test.rb
270
263
  - test/filters_test.rb
271
- - test/haml-spec/ruby_haml_test.rb
272
264
  - test/helper_test.rb
273
265
  - test/parser_test.rb
274
266
  - test/template_test.rb
@@ -1,111 +0,0 @@
1
- GIT
2
- remote: git://github.com/rails/activerecord-deprecated_finders.git
3
- revision: fe150f26f009cef370658b7c19db1629b2448952
4
- specs:
5
- activerecord-deprecated_finders (0.0.1)
6
-
7
- GIT
8
- remote: git://github.com/rails/journey.git
9
- revision: 850267edd7f19633a6868110d523f86f147c1653
10
- specs:
11
- journey (2.0.0.20120723141804)
12
-
13
- GIT
14
- remote: git://github.com/rails/rails.git
15
- revision: 8815de7b427196f00bd9f3406377928c2c269e22
16
- specs:
17
- actionmailer (4.0.0.beta)
18
- actionpack (= 4.0.0.beta)
19
- mail (~> 2.4.4)
20
- actionpack (4.0.0.beta)
21
- activesupport (= 4.0.0.beta)
22
- builder (~> 3.1.0)
23
- erubis (~> 2.7.0)
24
- journey (~> 2.0.0)
25
- rack (~> 1.4.1)
26
- rack-test (~> 0.6.1)
27
- activemodel (4.0.0.beta)
28
- activesupport (= 4.0.0.beta)
29
- builder (~> 3.1.0)
30
- activerecord (4.0.0.beta)
31
- activemodel (= 4.0.0.beta)
32
- activerecord-deprecated_finders (= 0.0.1)
33
- activesupport (= 4.0.0.beta)
34
- arel (~> 3.0.2)
35
- activesupport (4.0.0.beta)
36
- i18n (~> 0.6)
37
- minitest (~> 4.1)
38
- multi_json (~> 1.3)
39
- tzinfo (~> 0.3.33)
40
- rails (4.0.0.beta)
41
- actionmailer (= 4.0.0.beta)
42
- actionpack (= 4.0.0.beta)
43
- activerecord (= 4.0.0.beta)
44
- activesupport (= 4.0.0.beta)
45
- bundler (~> 1.2)
46
- railties (= 4.0.0.beta)
47
- sprockets-rails (~> 1.0)
48
- railties (4.0.0.beta)
49
- actionpack (= 4.0.0.beta)
50
- activesupport (= 4.0.0.beta)
51
- rake (>= 0.8.7)
52
- rdoc (~> 3.4)
53
- thor (>= 0.15.4, < 2.0)
54
-
55
- PATH
56
- remote: /Users/norman/work/haml/haml
57
- specs:
58
- haml (4.0.0.alpha.0)
59
- tilt
60
-
61
- GEM
62
- remote: http://rubygems.org/
63
- specs:
64
- arel (3.0.2)
65
- builder (3.1.3)
66
- erubis (2.7.0)
67
- hike (1.2.1)
68
- i18n (0.6.1)
69
- json (1.7.5)
70
- mail (2.4.4)
71
- i18n (>= 0.4.0)
72
- mime-types (~> 1.16)
73
- treetop (~> 1.4.8)
74
- mime-types (1.19)
75
- minitest (4.1.0)
76
- multi_json (1.3.6)
77
- nokogiri (1.5.5)
78
- polyglot (0.3.3)
79
- rack (1.4.1)
80
- rack-test (0.6.2)
81
- rack (>= 1.0)
82
- rake (0.9.2.2)
83
- rbench (0.2.3)
84
- rdoc (3.12)
85
- json (~> 1.4)
86
- sprockets (2.3.2)
87
- hike (~> 1.2)
88
- multi_json (~> 1.0)
89
- rack (~> 1.0)
90
- tilt (~> 1.1, != 1.3.0)
91
- sprockets-rails (1.0.0)
92
- railties (>= 4.0.0.beta, < 5.0)
93
- sprockets (~> 2.3.1)
94
- thor (0.16.0)
95
- tilt (1.3.3)
96
- treetop (1.4.10)
97
- polyglot
98
- polyglot (>= 0.3.1)
99
- tzinfo (0.3.33)
100
-
101
- PLATFORMS
102
- ruby
103
-
104
- DEPENDENCIES
105
- activerecord-deprecated_finders!
106
- haml!
107
- journey!
108
- minitest
109
- nokogiri
110
- rails!
111
- rbench
@@ -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
- }