mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
We no longer need haml-spec vendoring
This commit is contained in:
parent
b0237c9af4
commit
56138d662a
10 changed files with 21 additions and 842 deletions
9
Rakefile
9
Rakefile
|
@ -20,7 +20,14 @@ end
|
|||
namespace :haml do
|
||||
desc 'Run Haml Spec'
|
||||
task :spec do
|
||||
system('bundle exec rspec --pattern spec/haml-spec/**{,/\*/\*\*\}/\*_spec.rb')
|
||||
system('bundle exec rspec spec/haml_spec.rb')
|
||||
end
|
||||
|
||||
namespace :spec do
|
||||
desc 'Generate converted haml-spec'
|
||||
task :update do
|
||||
system('cd spec && rake convert')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'hamlit', path: '../..'
|
||||
gem 'minitest'
|
||||
gem 'tilt'
|
|
@ -1,22 +0,0 @@
|
|||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
hamlit (0.0.1)
|
||||
temple
|
||||
thor
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
minitest (5.5.1)
|
||||
temple (0.7.5)
|
||||
thor (0.19.1)
|
||||
tilt (2.0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
hamlit!
|
||||
minitest
|
||||
tilt
|
|
@ -1,14 +0,0 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
# Haml Spec #
|
||||
|
||||
Haml Spec provides a basic suite of tests for Haml interpreters.
|
||||
|
||||
It is intented for developers who are creating or maintaining an implementation
|
||||
of the [Haml](http://haml-lang.com) markup language.
|
||||
|
||||
At the moment, there are test runners for the [original
|
||||
Haml](http://github.com/nex3/haml) in Ruby, [Lua
|
||||
Haml](http://github.com/norman/lua-haml) and the
|
||||
[Text::Haml](http://github.com/vti/text-haml) Perl port. Support for other
|
||||
versions of Haml will be added if their developers/maintainers are interested in
|
||||
using it.
|
||||
|
||||
## The Tests ##
|
||||
|
||||
The tests are kept in JSON format for portability across languages. Each test
|
||||
is a JSON object with expected input, output, local variables and configuration
|
||||
parameters (see below). The test suite only provides tests for features which
|
||||
are portable, therefore no tests for script are provided, nor for external
|
||||
filters such as :markdown or :textile.
|
||||
|
||||
The one major exception to this are the tests for interpolation, which you may
|
||||
need to modify with a regular expression to run under PHP or Perl, which
|
||||
require a sigil before variable names. These tests are included despite being
|
||||
less than 100% portable because interpolation is an important part of Haml and
|
||||
can be tricky to implement. These tests are flagged as "optional" so that you
|
||||
can avoid running them if your implementation of Haml will not support this
|
||||
feature.
|
||||
|
||||
## Running the Tests ##
|
||||
|
||||
### Ruby ###
|
||||
|
||||
The Ruby test runner uses minitest, the same as the Ruby Haml implementation.
|
||||
To run the tests you probably only need to install `haml`, `minitest` and
|
||||
possibly `ruby` if your platform doesn't come with it by default. If you're
|
||||
using Ruby 1.8.x, you'll also need to install `json`:
|
||||
|
||||
sudo gem install haml
|
||||
sudo gem install minitest
|
||||
# for Ruby 1.8.x; check using "ruby --version" if unsure
|
||||
sudo gem install json
|
||||
|
||||
Then, running the Ruby test suite is easy:
|
||||
|
||||
ruby ruby_haml_test.rb
|
||||
|
||||
At the moment, running the tests with Ruby 1.8.7 fails because of issues with
|
||||
the JSON library. Please use 1.9.2 until this is resolved.
|
||||
|
||||
### Lua ###
|
||||
|
||||
The Lua test depends on
|
||||
[Penlight](http://stevedonovan.github.com/Penlight/),
|
||||
[Telescope](http://github.com/norman/telescope),
|
||||
[jason4lua](http://json.luaforge.net/), and
|
||||
[Lua Haml](http://github.com/norman/lua-haml). Install and run `tsc
|
||||
lua_haml_spec.lua`.
|
||||
|
||||
### Getting it ###
|
||||
|
||||
You can access the [Git repository](http://github.com/norman/haml-spec) at:
|
||||
|
||||
git://github.com/norman/haml-spec.git
|
||||
|
||||
Patches are *very* welcome, as are test runners for your Haml implementation.
|
||||
|
||||
As long as any test you add run against Ruby Haml and are not redundant, I'll
|
||||
be very happy to add them.
|
||||
|
||||
### Test JSON format ###
|
||||
|
||||
"test name" : {
|
||||
"haml" : "haml input",
|
||||
"html" : "expected html output",
|
||||
"result" : "expected test result",
|
||||
"locals" : "local vars",
|
||||
"config" : "config params",
|
||||
"optional" : true|false
|
||||
}
|
||||
|
||||
* test name: This should be a *very* brief description of what's being tested. It can
|
||||
be used by the test runners to name test methods, or to exclude certain tests from being
|
||||
run.
|
||||
* haml: The Haml code to be evaluated. Always required.
|
||||
* html: The HTML output that should be generated. Required unless "result" is "error".
|
||||
* result: Can be "pass" or "error". If it's absent, then "pass" is assumed. If it's "error",
|
||||
then the goal of the test is to make sure that malformed Haml code generates an error.
|
||||
* locals: An object containing local variables needed for the test.
|
||||
* config: An object containing configuration parameters used to run the test.
|
||||
The configuration parameters should be usable directly by Ruby's Haml with no
|
||||
modification. If your implementation uses config parameters with different
|
||||
names, you may need to process them to make them match your implementation.
|
||||
If your implementation has options that do not exist in Ruby's Haml, then you
|
||||
should add tests for this in your implementation's test rather than here.
|
||||
* optional: whether or not the test is optional
|
||||
|
||||
## License ##
|
||||
|
||||
This project is released under the [WTFPL](http://sam.zoy.org/wtfpl/) in order
|
||||
to be as usable as possible in any project, commercial or free.
|
||||
|
||||
## Author ##
|
||||
|
||||
[Norman Clarke](mailto:norman@njclarke.com)
|
|
@ -1,6 +0,0 @@
|
|||
desc 'Run haml-spec'
|
||||
task :spec do
|
||||
system('bundle exec ruby ruby_haml_test.rb')
|
||||
end
|
||||
|
||||
task default: :spec
|
|
@ -1,25 +0,0 @@
|
|||
$:.unshift File.expand_path('../../lib', __FILE__)
|
||||
|
||||
require "rubygems"
|
||||
require "minitest/autorun"
|
||||
require "json"
|
||||
require "hamlit"
|
||||
|
||||
class HamlTest < MiniTest::Unit::TestCase
|
||||
contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json"))
|
||||
contexts.each do |context|
|
||||
context[1].each do |name, test|
|
||||
define_method("test_spec: #{name} (#{context[0]})") do
|
||||
html = test["html"]
|
||||
haml = test["haml"]
|
||||
locals = Hash[(test["locals"] || {}).map {|x, y| [x.to_sym, y]}]
|
||||
options = Hash[(test["config"] || {}).map {|x, y| [x.to_sym, y]}]
|
||||
options[:format] = options[:format].to_sym if options.key?(:format)
|
||||
engine = Hamlit::Template.new(options) { haml }
|
||||
result = engine.render(Object.new, locals)
|
||||
|
||||
assert_equal html, result.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,660 +0,0 @@
|
|||
{
|
||||
"headers" : {
|
||||
|
||||
"an XHTML XML prolog" : {
|
||||
"haml" : "!!! XML",
|
||||
"html" : "<?xml version='1.0' encoding='utf-8' ?>",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an XHTML default (transitional) doctype" : {
|
||||
"haml" : "!!!",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an XHTML 1.1 doctype" : {
|
||||
"haml" : "!!! 1.1",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an XHTML 1.2 mobile doctype" : {
|
||||
"haml" : "!!! mobile",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an XHTML 1.1 basic doctype" : {
|
||||
"haml" : "!!! basic",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an XHTML 1.0 frameset doctype" : {
|
||||
"haml" : "!!! frameset",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 5 doctype with XHTML syntax" : {
|
||||
"haml" : "!!! 5",
|
||||
"html" : "<!DOCTYPE html>",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 5 XML prolog (silent)" : {
|
||||
"haml" : "!!! XML",
|
||||
"html" : "",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 5 doctype" : {
|
||||
"haml" : "!!!",
|
||||
"html" : "<!DOCTYPE html>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 4 XML prolog (silent)" : {
|
||||
"haml" : "!!! XML",
|
||||
"html" : "",
|
||||
"config" : {
|
||||
"format" : "html4"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 4 default (transitional) doctype" : {
|
||||
"haml" : "!!!",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
|
||||
"config" : {
|
||||
"format" : "html4"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 4 frameset doctype" : {
|
||||
"haml" : "!!! frameset",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
|
||||
"config" : {
|
||||
"format" : "html4"
|
||||
}
|
||||
},
|
||||
|
||||
"an HTML 4 strict doctype" : {
|
||||
"haml" : "!!! strict",
|
||||
"html" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
|
||||
"config" : {
|
||||
"format" : "html4"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"basic Haml tags and CSS": {
|
||||
|
||||
"a simple Haml tag" : {
|
||||
"haml" : "%p",
|
||||
"html" : "<p></p>"
|
||||
},
|
||||
|
||||
"a self-closing tag (XHTML)" : {
|
||||
"haml" : "%meta",
|
||||
"html" : "<meta />",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"a self-closing tag (HTML4)" : {
|
||||
"haml" : "%meta",
|
||||
"html" : "<meta>",
|
||||
"config" : {
|
||||
"format" : "html4"
|
||||
}
|
||||
},
|
||||
|
||||
"a self-closing tag (HTML5)" : {
|
||||
"haml" : "%meta",
|
||||
"html" : "<meta>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
},
|
||||
|
||||
"a self-closing tag ('/' modifier + XHTML)" : {
|
||||
"haml" : "%zzz/",
|
||||
"html" : "<zzz />",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"a self-closing tag ('/' modifier + HTML5)" : {
|
||||
"haml" : "%zzz/",
|
||||
"html" : "<zzz>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
},
|
||||
|
||||
"a tag with a CSS class" : {
|
||||
"haml" : "%p.class1",
|
||||
"html" : "<p class='class1'></p>"
|
||||
},
|
||||
|
||||
"a tag with multiple CSS classes" : {
|
||||
"haml" : "%p.class1.class2",
|
||||
"html" : "<p class='class1 class2'></p>"
|
||||
},
|
||||
|
||||
"a tag with a CSS id" : {
|
||||
"haml" : "%p#id1",
|
||||
"html" : "<p id='id1'></p>"
|
||||
},
|
||||
|
||||
"a tag with multiple CSS id's" : {
|
||||
"haml" : "%p#id1#id2",
|
||||
"html" : "<p id='id2'></p>"
|
||||
},
|
||||
|
||||
"a tag with a class followed by an id" : {
|
||||
"haml" : "%p.class1#id1",
|
||||
"html" : "<p class='class1' id='id1'></p>"
|
||||
},
|
||||
|
||||
"a tag with an id followed by a class" : {
|
||||
"haml" : "%p#id1.class1",
|
||||
"html" : "<p class='class1' id='id1'></p>"
|
||||
},
|
||||
|
||||
"an implicit div with a CSS id" : {
|
||||
"haml" : "#id1",
|
||||
"html" : "<div id='id1'></div>"
|
||||
},
|
||||
|
||||
"an implicit div with a CSS class" : {
|
||||
"haml" : ".class1",
|
||||
"html" : "<div class='class1'></div>"
|
||||
},
|
||||
|
||||
"multiple simple Haml tags" : {
|
||||
"haml" : "%div\n %div\n %p",
|
||||
"html" : "<div>\n <div>\n <p></p>\n </div>\n</div>"
|
||||
}
|
||||
},
|
||||
|
||||
"tags with unusual HTML characters" : {
|
||||
|
||||
"a tag with colons" : {
|
||||
"haml" : "%ns:tag",
|
||||
"html" : "<ns:tag></ns:tag>"
|
||||
},
|
||||
|
||||
"a tag with underscores" : {
|
||||
"haml" : "%snake_case",
|
||||
"html" : "<snake_case></snake_case>"
|
||||
},
|
||||
|
||||
"a tag with dashes" : {
|
||||
"haml" : "%dashed-tag",
|
||||
"html" : "<dashed-tag></dashed-tag>"
|
||||
},
|
||||
|
||||
"a tag with camelCase" : {
|
||||
"haml" : "%camelCase",
|
||||
"html" : "<camelCase></camelCase>"
|
||||
},
|
||||
|
||||
"a tag with PascalCase" : {
|
||||
"haml" : "%PascalCase",
|
||||
"html" : "<PascalCase></PascalCase>"
|
||||
}
|
||||
},
|
||||
|
||||
"tags with unusual CSS identifiers" : {
|
||||
|
||||
"an all-numeric class" : {
|
||||
"haml" : ".123",
|
||||
"html" : "<div class='123'></div>"
|
||||
},
|
||||
|
||||
"a class with underscores" : {
|
||||
"haml" : ".__",
|
||||
"html" : "<div class='__'></div>"
|
||||
},
|
||||
|
||||
"a class with dashes" : {
|
||||
"haml" : ".--",
|
||||
"html" : "<div class='--'></div>"
|
||||
}
|
||||
},
|
||||
|
||||
"tags with inline content" : {
|
||||
|
||||
"Inline content simple tag" : {
|
||||
"haml" : "%p hello",
|
||||
"html" : "<p>hello</p>"
|
||||
},
|
||||
|
||||
"Inline content tag with CSS" : {
|
||||
"haml" : "%p.class1 hello",
|
||||
"html" : "<p class='class1'>hello</p>"
|
||||
},
|
||||
|
||||
"Inline content multiple simple tags" : {
|
||||
"haml" : "%div\n %div\n %p text",
|
||||
"html" : "<div>\n <div>\n <p>text</p>\n </div>\n</div>"
|
||||
}
|
||||
},
|
||||
|
||||
"tags with nested content" : {
|
||||
|
||||
"Nested content simple tag" : {
|
||||
"haml" : "%p\n hello",
|
||||
"html" : "<p>\n hello\n</p>"
|
||||
},
|
||||
|
||||
"Nested content tag with CSS" : {
|
||||
"haml" : "%p.class1\n hello",
|
||||
"html" : "<p class='class1'>\n hello\n</p>"
|
||||
},
|
||||
|
||||
"Nested content multiple simple tags" : {
|
||||
"haml" : "%div\n %div\n %p\n text",
|
||||
"html" : "<div>\n <div>\n <p>\n text\n </p>\n </div>\n</div>"
|
||||
}
|
||||
},
|
||||
|
||||
"tags with HTML-style attributes": {
|
||||
|
||||
"HTML-style one attribute" : {
|
||||
"haml" : "%p(a='b')",
|
||||
"html" : "<p a='b'></p>"
|
||||
},
|
||||
|
||||
"HTML-style multiple attributes" : {
|
||||
"haml" : "%p(a='b' c='d')",
|
||||
"html" : "<p a='b' c='d'></p>"
|
||||
},
|
||||
|
||||
"HTML-style attributes separated with newlines" : {
|
||||
"haml" : "%p(a='b'\n c='d')",
|
||||
"html" : "<p a='b' c='d'></p>"
|
||||
},
|
||||
|
||||
"HTML-style interpolated attribute" : {
|
||||
"haml" : "%p(a=\"#{var}\")",
|
||||
"html" : "<p a='value'></p>",
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
},
|
||||
|
||||
"HTML-style 'class' as an attribute" : {
|
||||
"haml" : "%p(class='class1')",
|
||||
"html" : "<p class='class1'></p>"
|
||||
},
|
||||
|
||||
"HTML-style tag with a CSS class and 'class' as an attribute" : {
|
||||
"haml" : "%p.class2(class='class1')",
|
||||
"html" : "<p class='class1 class2'></p>"
|
||||
},
|
||||
|
||||
"HTML-style tag with 'id' as an attribute" : {
|
||||
"haml" : "%p(id='1')",
|
||||
"html" : "<p id='1'></p>"
|
||||
},
|
||||
|
||||
"HTML-style tag with a CSS id and 'id' as an attribute" : {
|
||||
"haml" : "%p#id(id='1')",
|
||||
"html" : "<p id='id_1'></p>"
|
||||
},
|
||||
|
||||
"HTML-style tag with a variable attribute" : {
|
||||
"haml" : "%p(class=var)",
|
||||
"html" : "<p class='hello'></p>",
|
||||
"locals" : {
|
||||
"var" : "hello"
|
||||
}
|
||||
},
|
||||
|
||||
"HTML-style tag with a CSS class and 'class' as a variable attribute" : {
|
||||
"haml" : ".hello(class=var)",
|
||||
"html" : "<div class='hello world'></div>",
|
||||
"locals" : {
|
||||
"var" : "world"
|
||||
}
|
||||
},
|
||||
|
||||
"HTML-style tag multiple CSS classes (sorted correctly)" : {
|
||||
"haml" : ".z(class=var)",
|
||||
"html" : "<div class='a z'></div>",
|
||||
"locals" : {
|
||||
"var" : "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"tags with Ruby-style attributes": {
|
||||
|
||||
"Ruby-style one attribute" : {
|
||||
"haml" : "%p{:a => 'b'}",
|
||||
"html" : "<p a='b'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style attributes hash with whitespace" : {
|
||||
"haml" : "%p{ :a => 'b' }",
|
||||
"html" : "<p a='b'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style interpolated attribute" : {
|
||||
"haml" : "%p{:a =>\"#{var}\"}",
|
||||
"html" : "<p a='value'></p>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
},
|
||||
|
||||
"Ruby-style multiple attributes" : {
|
||||
"haml" : "%p{ :a => 'b', 'c' => 'd' }",
|
||||
"html" : "<p a='b' c='d'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style attributes separated with newlines" : {
|
||||
"haml" : "%p{ :a => 'b',\n 'c' => 'd' }",
|
||||
"html" : "<p a='b' c='d'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style 'class' as an attribute" : {
|
||||
"haml" : "%p{:class => 'class1'}",
|
||||
"html" : "<p class='class1'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style tag with a CSS class and 'class' as an attribute" : {
|
||||
"haml" : "%p.class2{:class => 'class1'}",
|
||||
"html" : "<p class='class1 class2'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style tag with 'id' as an attribute" : {
|
||||
"haml" : "%p{:id => '1'}",
|
||||
"html" : "<p id='1'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style tag with a CSS id and 'id' as an attribute" : {
|
||||
"haml" : "%p#id{:id => '1'}",
|
||||
"html" : "<p id='id_1'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style tag with a CSS id and a numeric 'id' as an attribute" : {
|
||||
"haml" : "%p#id{:id => 1}",
|
||||
"html" : "<p id='id_1'></p>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"Ruby-style tag with a variable attribute" : {
|
||||
"haml" : "%p{:class => var}",
|
||||
"html" : "<p class='hello'></p>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "hello"
|
||||
}
|
||||
},
|
||||
|
||||
"Ruby-style tag with a CSS class and 'class' as a variable attribute" : {
|
||||
"haml" : ".hello{:class => var}",
|
||||
"html" : "<div class='hello world'></div>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "world"
|
||||
}
|
||||
},
|
||||
|
||||
"Ruby-style tag multiple CSS classes (sorted correctly)" : {
|
||||
"haml" : ".z{:class => var}",
|
||||
"html" : "<div class='a z'></div>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"silent comments" : {
|
||||
|
||||
"an inline silent comment" : {
|
||||
"haml" : "-# hello",
|
||||
"html" : ""
|
||||
},
|
||||
|
||||
"a nested silent comment" : {
|
||||
"haml" : "-#\n hello",
|
||||
"html" : ""
|
||||
},
|
||||
|
||||
"a multiply nested silent comment" : {
|
||||
"haml" : "-#\n %div\n foo",
|
||||
"html" : ""
|
||||
},
|
||||
|
||||
"a multiply nested silent comment with inconsistent indents" : {
|
||||
"haml" : "-#\n %div\n foo",
|
||||
"html" : ""
|
||||
}
|
||||
},
|
||||
|
||||
"markup comments" : {
|
||||
|
||||
"an inline markup comment" : {
|
||||
"haml" : "/ comment",
|
||||
"html" : "<!-- comment -->"
|
||||
},
|
||||
|
||||
"a nested markup comment" : {
|
||||
"haml" : "/\n comment\n comment2",
|
||||
"html" : "<!--\n comment\n comment2\n-->"
|
||||
}
|
||||
},
|
||||
|
||||
"conditional comments": {
|
||||
"a conditional comment" : {
|
||||
"haml" : "/[if IE]\n %p a",
|
||||
"html" : "<!--[if IE]>\n <p>a</p>\n<![endif]-->"
|
||||
}
|
||||
},
|
||||
|
||||
"internal filters": {
|
||||
|
||||
"content in an 'escaped' filter" : {
|
||||
"haml" : ":escaped\n <&\">",
|
||||
"html" : "<&">"
|
||||
},
|
||||
|
||||
"content in a 'preserve' filter" : {
|
||||
"haml" : ":preserve\n hello\n\n%p",
|
||||
"html" : "hello
\n<p></p>"
|
||||
},
|
||||
|
||||
"content in a 'plain' filter" : {
|
||||
"haml" : ":plain\n hello\n\n%p",
|
||||
"html" : "hello\n<p></p>"
|
||||
},
|
||||
|
||||
"content in a 'css' filter (XHTML)" : {
|
||||
"haml" : ":css\n hello\n\n%p",
|
||||
"html" : "<style type='text/css'>\n /*<![CDATA[*/\n hello\n /*]]>*/\n</style>\n<p></p>",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"content in a 'javascript' filter (XHTML)" : {
|
||||
"haml" : ":javascript\n a();\n%p",
|
||||
"html" : "<script type='text/javascript'>\n //<![CDATA[\n a();\n //]]>\n</script>\n<p></p>",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"content in a 'css' filter (HTML)" : {
|
||||
"haml" : ":css\n hello\n\n%p",
|
||||
"html" : "<style>\n hello\n</style>\n<p></p>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
},
|
||||
|
||||
"content in a 'javascript' filter (HTML)" : {
|
||||
"haml" : ":javascript\n a();\n%p",
|
||||
"html" : "<script>\n a();\n</script>\n<p></p>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Ruby-style interpolation": {
|
||||
|
||||
"interpolation inside inline content" : {
|
||||
"haml" : "%p #{var}",
|
||||
"html" : "<p>value</p>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
},
|
||||
|
||||
"no interpolation when escaped" : {
|
||||
"haml" : "%p \\#{var}",
|
||||
"html" : "<p>#{var}</p>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
},
|
||||
|
||||
"interpolation when the escape character is escaped" : {
|
||||
"haml" : "%p \\\\#{var}",
|
||||
"html" : "<p>\\value</p>",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
},
|
||||
|
||||
"interpolation inside filtered content" : {
|
||||
"haml" : ":plain\n #{var} interpolated: #{var}",
|
||||
"html" : "value interpolated: value",
|
||||
"optional" : true,
|
||||
"locals" : {
|
||||
"var" : "value"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"HTML escaping" : {
|
||||
|
||||
"code following '&='" : {
|
||||
"haml" : "&= '<\"&>'",
|
||||
"html" : "<"&>"
|
||||
},
|
||||
|
||||
"code following '=' when escape_haml is set to true" : {
|
||||
"haml" : "= '<\"&>'",
|
||||
"html" : "<"&>",
|
||||
"config" : {
|
||||
"escape_html" : "true"
|
||||
}
|
||||
},
|
||||
|
||||
"code following '!=' when escape_haml is set to true" : {
|
||||
"haml" : "!= '<\"&>'",
|
||||
"html" : "<\"&>",
|
||||
"config" : {
|
||||
"escape_html" : "true"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"boolean attributes" : {
|
||||
|
||||
"boolean attribute with XHTML" : {
|
||||
"haml" : "%input(checked=true)",
|
||||
"html" : "<input checked='checked' />",
|
||||
"config" : {
|
||||
"format" : "xhtml"
|
||||
}
|
||||
},
|
||||
|
||||
"boolean attribute with HTML" : {
|
||||
"haml" : "%input(checked=true)",
|
||||
"html" : "<input checked>",
|
||||
"config" : {
|
||||
"format" : "html5"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"whitespace preservation" : {
|
||||
|
||||
"following the '~' operator" : {
|
||||
"haml" : "~ \"Foo\\n<pre>Bar\\nBaz</pre>\"",
|
||||
"html" : "Foo\n<pre>Bar
Baz</pre>",
|
||||
"optional" : true
|
||||
},
|
||||
|
||||
"inside a textarea tag" : {
|
||||
"haml" : "%textarea\n hello\n hello",
|
||||
"html" : "<textarea>hello\nhello</textarea>"
|
||||
},
|
||||
|
||||
"inside a pre tag" : {
|
||||
"haml" : "%pre\n hello\n hello",
|
||||
"html" : "<pre>hello\nhello</pre>"
|
||||
}
|
||||
},
|
||||
|
||||
"whitespace removal" : {
|
||||
|
||||
"a tag with '>' appended and inline content" : {
|
||||
"haml" : "%li hello\n%li> world\n%li again",
|
||||
"html" : "<li>hello</li><li>world</li><li>again</li>"
|
||||
},
|
||||
|
||||
"a tag with '>' appended and nested content" : {
|
||||
"haml" : "%li hello\n%li>\n world\n%li again",
|
||||
"html" : "<li>hello</li><li>\n world\n</li><li>again</li>"
|
||||
},
|
||||
|
||||
"a tag with '<' appended" : {
|
||||
"haml" : "%p<\n hello\n world",
|
||||
"html" : "<p>hello\nworld</p>"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
$:.unshift File.expand_path('../../../lib', __FILE__)
|
||||
$:.unshift File.expand_path('../../lib', __FILE__)
|
||||
|
||||
require 'json'
|
||||
require 'unindent'
|
||||
require 'open-uri'
|
||||
|
||||
def generate_spec(test, locals, options)
|
||||
<<-SPEC
|
||||
|
@ -32,7 +33,8 @@ task :convert do
|
|||
|
||||
SPEC
|
||||
|
||||
contexts = JSON.parse(File.read(File.expand_path('../../../haml-spec/tests.json', __FILE__)))
|
||||
url = 'https://raw.githubusercontent.com/haml/haml-spec/master/tests.json'
|
||||
contexts = JSON.parse(open(url).read)
|
||||
contexts.each_with_index do |context, index|
|
||||
spec += "\n" if index != 0
|
||||
spec += " context \"#{context[0]}\" do\n"
|
||||
|
@ -59,7 +61,7 @@ task :convert do
|
|||
end
|
||||
|
||||
spec += "end\n"
|
||||
File.write('ruby_haml_spec.rb', spec)
|
||||
File.write('haml_spec.rb', spec)
|
||||
end
|
||||
|
||||
task default: :convert
|
|
@ -405,6 +405,14 @@ describe "haml" do
|
|||
options = {}
|
||||
assert_ugly(haml, locals, options)
|
||||
end
|
||||
|
||||
# FIXME: currently this is not considered
|
||||
pending "HTML-style tag with an atomic attribute" do
|
||||
haml = %q{%a(flag)}
|
||||
locals = {}
|
||||
options = {}
|
||||
assert_ugly(haml, locals, options)
|
||||
end
|
||||
end
|
||||
|
||||
context "tags with Ruby-style attributes" do
|
Loading…
Add table
Reference in a new issue