haml-edge 2.3.183 → 2.3.184
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/README.md +7 -7
- data/Rakefile +6 -4
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/lib/haml/filters.rb +5 -1
- data/lib/sass/script/functions.rb +23 -2
- data/lib/sass/script/lexer.rb +7 -5
- data/lib/sass/script/literal.rb +10 -0
- data/lib/sass/script/parser.rb +9 -2
- data/test/haml/engine_test.rb +9 -0
- data/test/sass/scss/css_test.rb +10 -1
- metadata +1 -36
- data/test/haml/spec/README.md +0 -97
- data/test/haml/spec/lua_haml_spec.lua +0 -30
- data/test/haml/spec/ruby_haml_test.rb +0 -19
- data/test/haml/spec/tests.json +0 -534
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/lib/fssm.rb +0 -33
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/path_spec.rb +0 -75
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.184
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ Sass is a little more complicated;
|
|
38
38
|
where they'll be automatically compiled
|
39
39
|
to corresponding CSS files in `public/stylesheets` when needed
|
40
40
|
(the Sass template directory is customizable...
|
41
|
-
see [the Sass reference](http://sass-lang.com/docs/yardoc/SASS_REFERENCE.
|
41
|
+
see [the Sass reference](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#template_location-option) for details).
|
42
42
|
|
43
43
|
For Merb, `.html.haml` views will work without any further modification.
|
44
44
|
To enable Sass, you also need to add a dependency.
|
@@ -129,7 +129,7 @@ like `if` and `while`:
|
|
129
129
|
= "Happy new " + "year!"
|
130
130
|
|
131
131
|
Haml provides far more tools than those presented here.
|
132
|
-
Check out the [reference documentation](http://beta.haml-lang.com/docs/yardoc/file.HAML_REFERENCE.
|
132
|
+
Check out the [reference documentation](http://beta.haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html)
|
133
133
|
for full details.
|
134
134
|
|
135
135
|
#### Indentation
|
@@ -151,10 +151,10 @@ and get small stylesheets up and running quickly,
|
|
151
151
|
particularly with the help of
|
152
152
|
[the Compass style library](http://compass-style.org).
|
153
153
|
|
154
|
-
[vars]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.
|
155
|
-
[nested]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.
|
154
|
+
[vars]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#variables_
|
155
|
+
[nested]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#nested_rules_
|
156
156
|
[mixins]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins
|
157
|
-
[imports]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.
|
157
|
+
[imports]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import
|
158
158
|
|
159
159
|
Sass has two syntaxes.
|
160
160
|
The one presented here, known as "SCSS" (for "Sassy CSS"),
|
@@ -163,7 +163,7 @@ The other (older) syntax, known as the indented syntax or just "Sass",
|
|
163
163
|
is whitespace-sensitive and indentation-based.
|
164
164
|
For more information, see the [reference documentation][syntax].
|
165
165
|
|
166
|
-
[syntax]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.
|
166
|
+
[syntax]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#syntax
|
167
167
|
|
168
168
|
To run the following examples and see the CSS they produce,
|
169
169
|
put them in a file called `test.scss` and run `sass test.scss`.
|
@@ -232,7 +232,7 @@ You can even give them arguments.
|
|
232
232
|
}
|
233
233
|
|
234
234
|
A comprehensive list of features is available
|
235
|
-
in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.
|
235
|
+
in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html).
|
236
236
|
|
237
237
|
## Executables
|
238
238
|
|
data/Rakefile
CHANGED
@@ -70,7 +70,7 @@ at_exit { File.delete(scope('REVISION')) rescue nil }
|
|
70
70
|
|
71
71
|
desc "Install Haml as a gem."
|
72
72
|
task :install => [:package] do
|
73
|
-
sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
|
73
|
+
sudo = RUBY_PLATFORM =~ /win32|mingw/ ? '' : 'sudo'
|
74
74
|
gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
|
75
75
|
sh %{#{sudo} #{gem} install --no-ri pkg/haml-#{File.read(scope('VERSION')).strip}}
|
76
76
|
end
|
@@ -191,14 +191,16 @@ task :release_edge do
|
|
191
191
|
sh %{git merge origin/master}
|
192
192
|
|
193
193
|
# Get the current master branch version
|
194
|
-
version = File.read(scope('VERSION')).strip.split('.')
|
195
|
-
|
194
|
+
version = File.read(scope('VERSION')).strip.split('.')
|
195
|
+
pr = version[3]
|
196
|
+
version = version.map {|n| n.to_i}
|
197
|
+
unless pr || (version[1] % 2 == 1 && version[2] == 0)
|
196
198
|
raise "#{version.join('.')} is not a development version"
|
197
199
|
end
|
198
200
|
|
199
201
|
# Bump the edge gem version
|
200
202
|
edge_version = File.read(scope('EDGE_GEM_VERSION')).strip.split('.').map {|n| n.to_i}
|
201
|
-
if edge_version[0..1] != version[0..1]
|
203
|
+
if !pr && (edge_version[0..1] != version[0..1])
|
202
204
|
# A new master branch version was released, reset the edge gem version
|
203
205
|
edge_version[0..1] = version[0..1]
|
204
206
|
edge_version[2] = 0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.184
|
data/VERSION_NAME
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Classy Cassidy
|
data/lib/haml/filters.rb
CHANGED
@@ -100,7 +100,11 @@ module Haml
|
|
100
100
|
if contains_interpolation?(text)
|
101
101
|
return if options[:suppress_eval]
|
102
102
|
|
103
|
-
text = unescape_interpolation(text).gsub(
|
103
|
+
text = unescape_interpolation(text).gsub(/(\\+)n/) do |s|
|
104
|
+
escapes = $1.size
|
105
|
+
next s if escapes % 2 == 0
|
106
|
+
("\\" * (escapes - 1)) + "\n"
|
107
|
+
end
|
104
108
|
newline if text.gsub!(/\n"\Z/, "\\n\"")
|
105
109
|
push_script <<RUBY.strip, :escape_html => false
|
106
110
|
find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options))
|
@@ -388,17 +388,38 @@ module Sass::Script
|
|
388
388
|
Sass::Script::Number.new(color.lightness, ["%"])
|
389
389
|
end
|
390
390
|
|
391
|
+
# Returns the alpha component (opacity) of a color.
|
392
|
+
# This is 1 unless otherwise specified.
|
393
|
+
#
|
394
|
+
# This function also supports the proprietary Microsoft
|
395
|
+
# `alpha(opacity=20)` syntax.
|
396
|
+
#
|
397
|
+
# @overload def alpha(color)
|
398
|
+
# @param color [Color]
|
399
|
+
# @return [Number]
|
400
|
+
# @raise [ArgumentError] If `color` isn't a color
|
401
|
+
def alpha(*args)
|
402
|
+
if args.all? do |a|
|
403
|
+
a.is_a?(Sass::Script::String) && a.type == :identifier &&
|
404
|
+
a.value =~ /^[a-zA-Z]+\s*=/
|
405
|
+
end
|
406
|
+
# Support the proprietary MS alpha() function
|
407
|
+
return Sass::Script::String.new("alpha(#{args.map {|a| a.to_s}.join(", ")})")
|
408
|
+
end
|
409
|
+
|
410
|
+
opacity(*args)
|
411
|
+
end
|
412
|
+
|
391
413
|
# Returns the alpha component (opacity) of a color.
|
392
414
|
# This is 1 unless otherwise specified.
|
393
415
|
#
|
394
416
|
# @param color [Color]
|
395
417
|
# @return [Number]
|
396
418
|
# @raise [ArgumentError] If `color` isn't a color
|
397
|
-
def
|
419
|
+
def opacity(color)
|
398
420
|
assert_type color, :Color
|
399
421
|
Sass::Script::Number.new(color.alpha)
|
400
422
|
end
|
401
|
-
alias_method :opacity, :alpha
|
402
423
|
|
403
424
|
# Makes a color more opaque.
|
404
425
|
# Takes a color and an amount between 0 and 1,
|
data/lib/sass/script/lexer.rb
CHANGED
@@ -196,11 +196,12 @@ module Sass
|
|
196
196
|
def read_token
|
197
197
|
return if done?
|
198
198
|
return unless value = token
|
199
|
+
type, val, size = value
|
200
|
+
size ||= @scanner.matched_size
|
199
201
|
|
200
|
-
|
201
|
-
Token.new(
|
202
|
-
current_position - @scanner.
|
203
|
-
@scanner.pos - @scanner.matched_size)
|
202
|
+
val.line = @line if val.is_a?(Script::Node)
|
203
|
+
Token.new(type, val, @line,
|
204
|
+
current_position - size, @scanner.pos - size)
|
204
205
|
end
|
205
206
|
|
206
207
|
def whitespace
|
@@ -272,7 +273,8 @@ module Sass
|
|
272
273
|
@offset = (c == 0 ? @offset + str2.size : str2[/\n(.*)/, 1].size)
|
273
274
|
[:special_fun,
|
274
275
|
Haml::Util.merge_adjacent_strings(
|
275
|
-
[str1] + Sass::Engine.parse_interp(str2, @line, @options))
|
276
|
+
[str1] + Sass::Engine.parse_interp(str2, @line, @options)),
|
277
|
+
str1.size + str2.size]
|
276
278
|
end
|
277
279
|
|
278
280
|
def ident_op
|
data/lib/sass/script/literal.rb
CHANGED
@@ -120,6 +120,16 @@ MSG
|
|
120
120
|
Sass::Script::String.new("#{self.to_s}, #{other.to_s}")
|
121
121
|
end
|
122
122
|
|
123
|
+
# The SassScript `=` operation
|
124
|
+
# (used for proprietary MS syntax like `alpha(opacity=20)`).
|
125
|
+
#
|
126
|
+
# @param other [Literal] The right-hand side of the operator
|
127
|
+
# @return [Script::String] A string containing both literals
|
128
|
+
# separated by `"="`
|
129
|
+
def single_eq(other)
|
130
|
+
Sass::Script::String.new("#{self.to_s}=#{other.to_s}")
|
131
|
+
end
|
132
|
+
|
123
133
|
# The SassScript `+` operation.
|
124
134
|
#
|
125
135
|
# @param other [Literal] The right-hand side of the operator
|
data/lib/sass/script/parser.rb
CHANGED
@@ -127,7 +127,7 @@ module Sass
|
|
127
127
|
|
128
128
|
# @private
|
129
129
|
PRECEDENCE = [
|
130
|
-
:comma, :concat, :or, :and,
|
130
|
+
:comma, :single_eq, :concat, :or, :and,
|
131
131
|
[:eq, :neq],
|
132
132
|
[:gt, :gte, :lt, :lte],
|
133
133
|
[:plus, :minus],
|
@@ -186,6 +186,7 @@ RUBY
|
|
186
186
|
def lexer_class; Lexer; end
|
187
187
|
|
188
188
|
production :expr, :interpolation, :comma
|
189
|
+
production :equals, :interpolation, :single_eq
|
189
190
|
|
190
191
|
def interpolation
|
191
192
|
e = concat
|
@@ -232,7 +233,7 @@ RUBY
|
|
232
233
|
end
|
233
234
|
node(Script::String.new(name.value, :identifier))
|
234
235
|
else
|
235
|
-
args =
|
236
|
+
args = fn_arglist || []
|
236
237
|
assert_tok(:rparen)
|
237
238
|
node(Script::Funcall.new(name.value, args))
|
238
239
|
end
|
@@ -260,6 +261,12 @@ RUBY
|
|
260
261
|
[[var, val], *defn_arglist(val)]
|
261
262
|
end
|
262
263
|
|
264
|
+
def fn_arglist
|
265
|
+
return unless e = equals
|
266
|
+
return [e] unless try_tok(:comma)
|
267
|
+
[e, *fn_arglist]
|
268
|
+
end
|
269
|
+
|
263
270
|
def arglist
|
264
271
|
return unless e = interpolation
|
265
272
|
return [e] unless try_tok(:comma)
|
data/test/haml/engine_test.rb
CHANGED
@@ -671,6 +671,15 @@ HAML
|
|
671
671
|
assert_equal("<a href='#\"'></a>\n", render('%a(href="#\\"")'))
|
672
672
|
end
|
673
673
|
|
674
|
+
def test_filter_with_newline_and_interp
|
675
|
+
assert_equal(<<HTML, render(<<HAML))
|
676
|
+
\\n
|
677
|
+
HTML
|
678
|
+
:plain
|
679
|
+
\\n\#{""}
|
680
|
+
HAML
|
681
|
+
end
|
682
|
+
|
674
683
|
# HTML escaping tests
|
675
684
|
|
676
685
|
def test_ampersand_equals_should_escape
|
data/test/sass/scss/css_test.rb
CHANGED
@@ -320,7 +320,7 @@ foo {
|
|
320
320
|
SCSS
|
321
321
|
end
|
322
322
|
|
323
|
-
def
|
323
|
+
def test_ms_long_filter_syntax
|
324
324
|
assert_equal <<CSS, render(<<SCSS)
|
325
325
|
foo {
|
326
326
|
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000);
|
@@ -332,6 +332,15 @@ foo {
|
|
332
332
|
SCSS
|
333
333
|
end
|
334
334
|
|
335
|
+
def test_ms_short_filter_syntax
|
336
|
+
assert_parses <<SCSS
|
337
|
+
foo {
|
338
|
+
filter: alpha(opacity=20);
|
339
|
+
filter: alpha(opacity=20, enabled=true);
|
340
|
+
filter: blaznicate(foo=bar, baz=bang bip, bart=#fa4600); }
|
341
|
+
SCSS
|
342
|
+
end
|
343
|
+
|
335
344
|
def test_declaration_hacks
|
336
345
|
assert_parses <<SCSS
|
337
346
|
foo {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.184
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -123,36 +123,6 @@ files:
|
|
123
123
|
- lib/sass/scss/rx.rb
|
124
124
|
- lib/sass/scss/script_lexer.rb
|
125
125
|
- lib/sass/scss/script_parser.rb
|
126
|
-
- vendor/fssm/LICENSE
|
127
|
-
- vendor/fssm/README.markdown
|
128
|
-
- vendor/fssm/Rakefile
|
129
|
-
- vendor/fssm/VERSION.yml
|
130
|
-
- vendor/fssm/example.rb
|
131
|
-
- vendor/fssm/fssm.gemspec
|
132
|
-
- vendor/fssm/lib/fssm.rb
|
133
|
-
- vendor/fssm/lib/fssm/backends/fsevents.rb
|
134
|
-
- vendor/fssm/lib/fssm/backends/inotify.rb
|
135
|
-
- vendor/fssm/lib/fssm/backends/polling.rb
|
136
|
-
- vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb
|
137
|
-
- vendor/fssm/lib/fssm/monitor.rb
|
138
|
-
- vendor/fssm/lib/fssm/path.rb
|
139
|
-
- vendor/fssm/lib/fssm/pathname.rb
|
140
|
-
- vendor/fssm/lib/fssm/state/directory.rb
|
141
|
-
- vendor/fssm/lib/fssm/state/file.rb
|
142
|
-
- vendor/fssm/lib/fssm/support.rb
|
143
|
-
- vendor/fssm/lib/fssm/tree.rb
|
144
|
-
- vendor/fssm/profile/prof-cache.rb
|
145
|
-
- vendor/fssm/profile/prof-fssm-pathname.html
|
146
|
-
- vendor/fssm/profile/prof-pathname.rb
|
147
|
-
- vendor/fssm/profile/prof-plain-pathname.html
|
148
|
-
- vendor/fssm/profile/prof.html
|
149
|
-
- vendor/fssm/spec/path_spec.rb
|
150
|
-
- vendor/fssm/spec/root/duck/quack.txt
|
151
|
-
- vendor/fssm/spec/root/file.css
|
152
|
-
- vendor/fssm/spec/root/file.rb
|
153
|
-
- vendor/fssm/spec/root/file.yml
|
154
|
-
- vendor/fssm/spec/root/moo/cow.txt
|
155
|
-
- vendor/fssm/spec/spec_helper.rb
|
156
126
|
- bin/css2sass
|
157
127
|
- bin/haml
|
158
128
|
- bin/html2haml
|
@@ -187,10 +157,6 @@ files:
|
|
187
157
|
- test/haml/results/tag_parsing.xhtml
|
188
158
|
- test/haml/results/very_basic.xhtml
|
189
159
|
- test/haml/results/whitespace_handling.xhtml
|
190
|
-
- test/haml/spec/README.md
|
191
|
-
- test/haml/spec/lua_haml_spec.lua
|
192
|
-
- test/haml/spec/ruby_haml_test.rb
|
193
|
-
- test/haml/spec/tests.json
|
194
160
|
- test/haml/template_test.rb
|
195
161
|
- test/haml/util_test.rb
|
196
162
|
- test/haml/templates/_av_partial_1.haml
|
@@ -349,7 +315,6 @@ test_files:
|
|
349
315
|
- test/haml/engine_test.rb
|
350
316
|
- test/haml/helper_test.rb
|
351
317
|
- test/haml/html2haml_test.rb
|
352
|
-
- test/haml/spec/ruby_haml_test.rb
|
353
318
|
- test/haml/template_test.rb
|
354
319
|
- test/haml/util_test.rb
|
355
320
|
- test/haml/spec_test.rb
|
data/test/haml/spec/README.md
DELETED
@@ -1,97 +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 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)
|
@@ -1,30 +0,0 @@
|
|
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)
|
@@ -1,19 +0,0 @@
|
|
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
|