haml-edge 2.3.100 → 2.3.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +3 -0
- data/EDGE_GEM_VERSION +1 -1
- data/Rakefile +14 -2
- data/VERSION +1 -1
- data/extra/haml-mode.el +97 -11
- data/extra/sass-mode.el +2 -2
- data/lib/haml/engine.rb +2 -2
- data/lib/haml/exec.rb +121 -25
- data/lib/haml/filters.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +2 -1
- data/lib/haml/helpers/xss_mods.rb +43 -13
- data/lib/haml/helpers.rb +38 -17
- data/lib/haml/html.rb +13 -4
- data/lib/haml/precompiler.rb +24 -3
- data/lib/haml/template/plugin.rb +7 -3
- data/lib/haml/template.rb +3 -3
- data/lib/haml/util.rb +40 -0
- data/lib/sass/callbacks.rb +50 -0
- data/lib/sass/css.rb +1 -1
- data/lib/sass/engine.rb +45 -5
- data/lib/sass/error.rb +6 -3
- data/lib/sass/files.rb +8 -1
- data/lib/sass/plugin/rails.rb +2 -2
- data/lib/sass/plugin.rb +260 -28
- data/lib/sass/script/color.rb +216 -30
- data/lib/sass/script/functions.rb +356 -74
- data/lib/sass/script/lexer.rb +7 -4
- data/lib/sass/script/number.rb +2 -0
- data/lib/sass/script/parser.rb +1 -1
- data/lib/sass/script.rb +3 -0
- data/lib/sass/tree/node.rb +1 -1
- data/lib/sass/tree/root_node.rb +6 -0
- data/lib/sass/tree/rule_node.rb +1 -0
- data/lib/sass.rb +4 -0
- data/test/haml/engine_test.rb +25 -0
- data/test/haml/helper_test.rb +81 -1
- data/test/haml/html2haml_test.rb +13 -0
- data/test/haml/spec/README.md +97 -0
- data/test/haml/spec/lua_haml_spec.lua +30 -0
- data/test/haml/spec/ruby_haml_test.rb +19 -0
- data/test/haml/spec/tests.json +534 -0
- data/test/haml/spec_test.rb +0 -0
- data/test/haml/template_test.rb +18 -4
- data/test/haml/util_test.rb +0 -0
- data/test/sass/callbacks_test.rb +61 -0
- data/test/sass/css2sass_test.rb +1 -0
- data/test/sass/engine_test.rb +70 -14
- data/test/sass/functions_test.rb +223 -3
- data/test/sass/plugin_test.rb +193 -25
- data/test/sass/results/options.css +1 -0
- data/test/sass/script_test.rb +5 -5
- data/test/sass/templates/options.sass +2 -0
- data/test/test_helper.rb +12 -5
- metadata +19 -9
data/test/haml/engine_test.rb
CHANGED
@@ -72,6 +72,7 @@ class EngineTest < Test::Unit::TestCase
|
|
72
72
|
"/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3],
|
73
73
|
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
|
74
74
|
"foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
75
|
+
"foo\n:erb\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
75
76
|
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
76
77
|
}
|
77
78
|
|
@@ -283,6 +284,10 @@ RESULT
|
|
283
284
|
SOURCE
|
284
285
|
end
|
285
286
|
|
287
|
+
def test_nil_option
|
288
|
+
assert_equal("<p foo='bar'></p>\n", render('%p{:foo => "bar"}', :attr_wrapper => nil))
|
289
|
+
end
|
290
|
+
|
286
291
|
# Regression tests
|
287
292
|
|
288
293
|
def test_whitespace_nuke_with_both_newlines
|
@@ -568,6 +573,17 @@ HTML
|
|
568
573
|
HAML
|
569
574
|
end
|
570
575
|
|
576
|
+
def test_erb_filter_with_multiline_expr
|
577
|
+
assert_equal(<<HTML, render(<<HAML))
|
578
|
+
foobarbaz
|
579
|
+
HTML
|
580
|
+
:erb
|
581
|
+
<%= "foo" +
|
582
|
+
"bar" +
|
583
|
+
"baz" %>
|
584
|
+
HAML
|
585
|
+
end
|
586
|
+
|
571
587
|
def test_silent_script_with_hyphen_case
|
572
588
|
assert_equal("", render("- 'foo-case-bar-case'"))
|
573
589
|
end
|
@@ -596,6 +612,15 @@ HTML
|
|
596
612
|
HAML
|
597
613
|
end
|
598
614
|
|
615
|
+
def test_html_attributes_with_hash
|
616
|
+
assert_equal("<a href='#' rel='top'>Foo</a>\n",
|
617
|
+
render('%a(href="#" rel="top") Foo'))
|
618
|
+
assert_equal("<a href='#'>Foo</a>\n",
|
619
|
+
render('%a(href="#") #{"Foo"}'))
|
620
|
+
|
621
|
+
assert_equal("<a href='#\"'></a>\n", render('%a(href="#\\"")'))
|
622
|
+
end
|
623
|
+
|
599
624
|
# HTML escaping tests
|
600
625
|
|
601
626
|
def test_ampersand_equals_should_escape
|
data/test/haml/helper_test.rb
CHANGED
@@ -73,7 +73,7 @@ class HelperTest < Test::Unit::TestCase
|
|
73
73
|
|
74
74
|
begin
|
75
75
|
ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>")
|
76
|
-
rescue NoMethodError,
|
76
|
+
rescue NoMethodError, Haml::Util.av_template_class(:Error)
|
77
77
|
proper_behavior = true
|
78
78
|
end
|
79
79
|
assert(proper_behavior)
|
@@ -125,6 +125,50 @@ HTML
|
|
125
125
|
HAML
|
126
126
|
end
|
127
127
|
|
128
|
+
def test_haml_tag_name_attribute_with_id
|
129
|
+
assert_equal("<p id='some_id'></p>\n", render("- haml_tag 'p#some_id'"))
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_haml_tag_without_name_but_with_id
|
133
|
+
assert_equal("<div id='some_id'></div>\n", render("- haml_tag '#some_id'"))
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_haml_tag_without_name_but_with_class
|
137
|
+
assert_equal("<div class='foo'></div>\n", render("- haml_tag '.foo'"))
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_haml_tag_name_with_id_and_class
|
141
|
+
assert_equal("<p class='foo' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo'"))
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_haml_tag_name_with_class
|
145
|
+
assert_equal("<p class='foo'></p>\n", render("- haml_tag 'p.foo'"))
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_haml_tag_name_with_class_and_id
|
149
|
+
assert_equal("<p class='foo' id='some_id'></p>\n", render("- haml_tag 'p.foo#some_id'"))
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_haml_tag_name_with_id_and_multiple_classes
|
153
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo.bar'"))
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_haml_tag_name_with_multiple_classes_and_id
|
157
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p.foo.bar#some_id'"))
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_haml_tag_name_and_attribute_classes_merging
|
161
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo', :class => 'bar'"))
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_haml_tag_name_and_attribute_classes_merging
|
165
|
+
assert_equal("<p class='bar foo'></p>\n", render("- haml_tag 'p.foo', :class => 'bar'"))
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_haml_tag_name_merges_id_and_attribute_id
|
169
|
+
assert_equal("<p id='foo_bar'></p>\n", render("- haml_tag 'p#foo', :id => 'bar'"))
|
170
|
+
end
|
171
|
+
|
128
172
|
def test_haml_tag_attribute_html_escaping
|
129
173
|
assert_equal("<p id='foo&bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
|
130
174
|
end
|
@@ -157,6 +201,42 @@ HAML
|
|
157
201
|
assert_raise(Haml::Error) { render("= haml_tag :p") }
|
158
202
|
end
|
159
203
|
|
204
|
+
def test_haml_tag_with_multiline_string
|
205
|
+
assert_equal(<<HTML, render(<<HAML))
|
206
|
+
<p>
|
207
|
+
foo
|
208
|
+
bar
|
209
|
+
baz
|
210
|
+
</p>
|
211
|
+
HTML
|
212
|
+
- haml_tag :p, "foo\\nbar\\nbaz"
|
213
|
+
HAML
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_haml_concat_with_multiline_string
|
217
|
+
assert_equal(<<HTML, render(<<HAML))
|
218
|
+
<p>
|
219
|
+
foo
|
220
|
+
bar
|
221
|
+
baz
|
222
|
+
</p>
|
223
|
+
HTML
|
224
|
+
%p
|
225
|
+
- haml_concat "foo\\nbar\\nbaz"
|
226
|
+
HAML
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_haml_tag_with_ugly
|
230
|
+
assert_equal(<<HTML, render(<<HAML, :ugly => true))
|
231
|
+
<p>
|
232
|
+
<strong>Hi!</strong>
|
233
|
+
</p>
|
234
|
+
HTML
|
235
|
+
- haml_tag :p do
|
236
|
+
- haml_tag :strong, "Hi!"
|
237
|
+
HAML
|
238
|
+
end
|
239
|
+
|
160
240
|
def test_is_haml
|
161
241
|
assert(!ActionView::Base.new.is_haml?)
|
162
242
|
assert_equal("true\n", render("= is_haml?"))
|
data/test/haml/html2haml_test.rb
CHANGED
@@ -8,6 +8,19 @@ class Html2HamlTest < Test::Unit::TestCase
|
|
8
8
|
assert_equal '', render('')
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_doctype
|
12
|
+
assert_equal '!!!', render("<!DOCTYPE html>")
|
13
|
+
assert_equal '!!! 1.1', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">')
|
14
|
+
assert_equal '!!! Strict', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
|
15
|
+
assert_equal '!!! Frameset', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">')
|
16
|
+
assert_equal '!!! Mobile 1.2', render('<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">')
|
17
|
+
assert_equal '!!! Basic 1.1', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">')
|
18
|
+
assert_equal '!!!', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
|
19
|
+
assert_equal '!!! Strict', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">')
|
20
|
+
assert_equal '!!! Frameset', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">')
|
21
|
+
assert_equal '!!!', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">')
|
22
|
+
end
|
23
|
+
|
11
24
|
def test_id_and_class_should_be_removed_from_hash
|
12
25
|
assert_equal '%span#foo.bar', render('<span id="foo" class="bar"> </span>')
|
13
26
|
end
|
@@ -0,0 +1,97 @@
|
|
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 Haml](http://github.com/nex3/haml)
|
9
|
+
in Ruby, and for [Lua Haml](http://github.com/norman/lua-haml). Support for
|
10
|
+
other versions of Haml will be added if their developers/maintainers
|
11
|
+
are interested in using it.
|
12
|
+
|
13
|
+
## The Tests ##
|
14
|
+
|
15
|
+
The tests are kept in JSON format for portability across languages. Each test
|
16
|
+
is a JSON object with expected input, output, local variables and configuration
|
17
|
+
parameters (see below). The test suite only provides tests for features which
|
18
|
+
are portable, therefore no tests for script are provided, nor for external
|
19
|
+
filters such as :markdown or :textile.
|
20
|
+
|
21
|
+
The one major exception to this are the tests for interpolation, which you may
|
22
|
+
need to modify with a regular expression to run under PHP or Perl, which
|
23
|
+
require a symbol before variable names. These tests are included despite being
|
24
|
+
less than 100% portable because interpolation is an important part of Haml and
|
25
|
+
can be tricky to implement.
|
26
|
+
|
27
|
+
## Running the Tests ##
|
28
|
+
|
29
|
+
### Ruby ###
|
30
|
+
|
31
|
+
In order to make it as easy as possible for non-Ruby programmers to run the
|
32
|
+
Ruby Haml tests, the Ruby test runner uses test/unit, rather than something
|
33
|
+
fancier like Rspec. To run them you probably only need to install `haml`, and
|
34
|
+
possibly `ruby` if your platform doesn't come with it by default. If you're
|
35
|
+
using Ruby 1.8.x, you'll also need to install `json`:
|
36
|
+
|
37
|
+
sudo gem install haml
|
38
|
+
# for Ruby 1.8.x; check using "ruby --version" if unsure
|
39
|
+
sudo gem install json
|
40
|
+
|
41
|
+
Then, running the Ruby test suite is easy:
|
42
|
+
|
43
|
+
ruby ruby_haml_test.rb
|
44
|
+
|
45
|
+
### Lua ###
|
46
|
+
|
47
|
+
The Lua test depends on [Telescope](http://telescope.luaforge.net/),
|
48
|
+
[jason4lua](http://json.luaforge.net/), and
|
49
|
+
[Lua Haml](http://github.com/norman/lua-haml). Install and
|
50
|
+
run `tsc lua_haml_spec.lua`.
|
51
|
+
|
52
|
+
## Contributing ##
|
53
|
+
|
54
|
+
### Getting it ###
|
55
|
+
|
56
|
+
You can access the [Git repository](http://github.com/norman/haml-spec) at:
|
57
|
+
|
58
|
+
git://github.com/norman/haml-spec.git
|
59
|
+
|
60
|
+
Patches are *very* welcome, as are test runners for your Haml implementation.
|
61
|
+
|
62
|
+
As long as any test you add run against Ruby Haml and are not redundant, I'll
|
63
|
+
be very happy to add them.
|
64
|
+
|
65
|
+
### Test JSON format ###
|
66
|
+
|
67
|
+
"test name" : {
|
68
|
+
"haml" : "haml input",
|
69
|
+
"html" : "expected html output",
|
70
|
+
"result" : "expected test result",
|
71
|
+
"locals" : "local vars",
|
72
|
+
"config" : "config params"
|
73
|
+
}
|
74
|
+
|
75
|
+
* test name: This should be a *very* brief description of what's being tested. It can
|
76
|
+
be used by the test runners to name test methods, or to exclude certain tests from being
|
77
|
+
run.
|
78
|
+
* haml: The Haml code to be evaluated. Always required.
|
79
|
+
* html: The HTML output that should be generated. Required unless "result" is "error".
|
80
|
+
* result: Can be "pass" or "error". If it's absent, then "pass" is assumed. If it's "error",
|
81
|
+
then the goal of the test is to make sure that malformed Haml code generates an error.
|
82
|
+
* locals: An object containing local variables needed for the test.
|
83
|
+
* config: An object containing configuration parameters used to run the test.
|
84
|
+
The configuration parameters should be usable directly by Ruby's Haml with no
|
85
|
+
modification. If your implementation uses config parameters with different
|
86
|
+
names, you may need to process them to make them match your implementation.
|
87
|
+
If your implementation has options that do not exist in Ruby's Haml, then you
|
88
|
+
should add tests for this in your implementation's test rather than here.
|
89
|
+
|
90
|
+
## License ##
|
91
|
+
|
92
|
+
This project is released under the [WTFPL](http://sam.zoy.org/wtfpl/) in order
|
93
|
+
to be as usable as possible in any project, commercial or free.
|
94
|
+
|
95
|
+
## Author ##
|
96
|
+
|
97
|
+
[Norman Clarke](mailto:norman@njclarke.com)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'luarocks.require'
|
2
|
+
require 'json'
|
3
|
+
require 'telescope'
|
4
|
+
require 'haml'
|
5
|
+
|
6
|
+
local function get_tests(filename)
|
7
|
+
local self = debug.getinfo(1).short_src
|
8
|
+
if self:match("/") then return "./" .. self:gsub("[^/]*%.lua$", "/" .. filename)
|
9
|
+
elseif self:match("\\") then return self:gsub("[^\\]*%.lua$", "\\" .. filename)
|
10
|
+
else return filename
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
local fh = assert(io.open(get_tests("tests.json")))
|
15
|
+
local input = fh:read '*a'
|
16
|
+
fh:close()
|
17
|
+
|
18
|
+
local contexts = json.decode(input)
|
19
|
+
|
20
|
+
describe("LuaHaml", function()
|
21
|
+
for context, expectations in pairs(contexts) do
|
22
|
+
describe("When handling " .. context, function()
|
23
|
+
for name, exp in pairs(expectations) do
|
24
|
+
it(string.format("should correctly render %s", name), function()
|
25
|
+
assert_equal(haml.render(exp.haml, exp.config or {}, exp.locals or {}), exp.html)
|
26
|
+
end)
|
27
|
+
end
|
28
|
+
end)
|
29
|
+
end
|
30
|
+
end)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "json"
|
3
|
+
require "haml"
|
4
|
+
|
5
|
+
class HamlTest < Test::Unit::TestCase
|
6
|
+
contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json"))
|
7
|
+
contexts.each do |context|
|
8
|
+
context[1].each do |name, test|
|
9
|
+
class_eval(<<-EOTEST)
|
10
|
+
def test_#{name.gsub(/\s+|[^a-zA-Z0-9_]/, "_")}
|
11
|
+
locals = Hash[*(#{test}["locals"] || {}).collect {|k, v| [k.to_sym, v] }.flatten]
|
12
|
+
options = Hash[*(#{test}["config"] || {}).collect {|k, v| [k.to_sym, v.to_sym] }.flatten]
|
13
|
+
engine = Haml::Engine.new(#{test}["haml"], options)
|
14
|
+
assert_equal(engine.render(Object.new, locals).chomp, #{test}["html"])
|
15
|
+
end
|
16
|
+
EOTEST
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|