slim 1.0.2 → 1.0.3
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/.gitignore +0 -1
- data/.travis.yml +2 -1
- data/CHANGES +11 -0
- data/README.md +3 -0
- data/lib/slim/embedded_engine.rb +3 -20
- data/lib/slim/interpolation.rb +3 -3
- data/lib/slim/parser.rb +4 -3
- data/lib/slim/template.rb +1 -1
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +2 -4
- data/test/rails/app/controllers/slim_controller.rb +9 -2
- data/test/rails/app/views/layouts/application.html.slim +1 -1
- data/test/rails/config/database.yml +1 -19
- data/test/rails/test/{test_slim_rails.rb → test_slim.rb} +14 -3
- data/test/slim/helper.rb +14 -2
- data/test/slim/test_code_output.rb +16 -0
- data/test/slim/test_embedded_engines.rb +10 -31
- data/test/slim/test_html_structure.rb +3 -3
- data/test/slim/test_pretty.rb +20 -0
- data/test/slim/test_ruby_errors.rb +11 -14
- data/test/slim/test_slim_template.rb +14 -19
- metadata +23 -45
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -8,8 +8,9 @@ rvm:
|
|
8
8
|
env:
|
9
9
|
- "TASK=test"
|
10
10
|
- "TASK=test TEMPLE=master"
|
11
|
-
- "TASK=test:rails
|
11
|
+
# - "TASK=test:rails RAILS=master"
|
12
12
|
- "TASK=test:rails RAILS=3.0.10"
|
13
|
+
- "TASK=test:rails RAILS=3.1.0"
|
13
14
|
script: "bundle exec rake test:ci"
|
14
15
|
notifications:
|
15
16
|
email: false
|
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
master
|
2
2
|
|
3
|
+
1.0.3
|
4
|
+
|
5
|
+
* Fix rubinius test cases
|
6
|
+
* Fix line numbers for embedded engines
|
7
|
+
* Require temple 0.3.4
|
8
|
+
* Remove dynamic embedded engines Haml, Liquid, Radius, Markaby
|
9
|
+
* More thorough integration testing using travis-ci
|
10
|
+
See http://travis-ci.org/#!/stonean/slim
|
11
|
+
* Empty static attributes are not removed anymore
|
12
|
+
* Line indicator =' is supported in tags
|
13
|
+
|
3
14
|
1.0.2
|
4
15
|
|
5
16
|
* Support for Rails 3.1 streaming (Temple > 0.3.2 required)
|
data/README.md
CHANGED
@@ -303,18 +303,21 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
303
303
|
(1) slim 4.330000 0.020000 4.350000 ( 4.495633)
|
304
304
|
(1) haml 4.680000 0.020000 4.700000 ( 4.747019)
|
305
305
|
(1) haml ugly 4.530000 0.020000 4.550000 ( 4.592425)
|
306
|
+
|
306
307
|
(2) erb 0.240000 0.000000 0.240000 ( 0.235896)
|
307
308
|
(2) erubis 0.180000 0.000000 0.180000 ( 0.185349)
|
308
309
|
(2) fast erubis 0.150000 0.000000 0.150000 ( 0.154970)
|
309
310
|
(2) slim 0.050000 0.000000 0.050000 ( 0.046685)
|
310
311
|
(2) haml 0.490000 0.000000 0.490000 ( 0.497864)
|
311
312
|
(2) haml ugly 0.420000 0.000000 0.420000 ( 0.428596)
|
313
|
+
|
312
314
|
(3) erb 0.030000 0.000000 0.030000 ( 0.033979)
|
313
315
|
(3) erubis 0.030000 0.000000 0.030000 ( 0.030705)
|
314
316
|
(3) fast erubis 0.040000 0.000000 0.040000 ( 0.035229)
|
315
317
|
(3) slim 0.040000 0.000000 0.040000 ( 0.036249)
|
316
318
|
(3) haml 0.160000 0.000000 0.160000 ( 0.165024)
|
317
319
|
(3) haml ugly 0.150000 0.000000 0.150000 ( 0.146130)
|
320
|
+
|
318
321
|
(4) erb 0.060000 0.000000 0.060000 ( 0.059847)
|
319
322
|
(4) erubis 0.040000 0.000000 0.040000 ( 0.040770)
|
320
323
|
(4) slim 0.040000 0.000000 0.040000 ( 0.047389)
|
data/lib/slim/embedded_engine.rb
CHANGED
@@ -127,18 +127,6 @@ module Slim
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
# Tilt-based engine which is fully dynamically evaluated during runtime (Slow and uncached)
|
131
|
-
class DynamicTiltEngine < TiltEngine
|
132
|
-
protected
|
133
|
-
|
134
|
-
# Code to collect local variables
|
135
|
-
COLLECT_LOCALS = %q{eval('{' + local_variables.select {|v| v[0] != ?_ }.map {|v| ":#{v}=>#{v}" }.join(',') + '}')}
|
136
|
-
|
137
|
-
def render(engine, text)
|
138
|
-
[:dynamic, "#{engine.name}.new { #{text.inspect} }.render(self, #{COLLECT_LOCALS})"]
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
130
|
# Tilt-based engine which is precompiled
|
143
131
|
class PrecompiledTiltEngine < TiltEngine
|
144
132
|
protected
|
@@ -177,7 +165,7 @@ module Slim
|
|
177
165
|
# Generates a html tag and wraps another engine (specified via :engine option)
|
178
166
|
class TagEngine < Filter
|
179
167
|
def on_slim_embedded(engine, body)
|
180
|
-
content = options[:engine] ? options[:engine].new(options).on_slim_embedded(engine, body) :
|
168
|
+
content = options[:engine] ? options[:engine].new(options).on_slim_embedded(engine, body) : body
|
181
169
|
[:html, :tag, options[:tag], [:html, :attrs, *options[:attributes].map {|k, v| [:html, :attr, k, [:static, v]] }], content]
|
182
170
|
end
|
183
171
|
end
|
@@ -185,7 +173,7 @@ module Slim
|
|
185
173
|
# Embeds ruby code
|
186
174
|
class RubyEngine < Filter
|
187
175
|
def on_slim_embedded(engine, body)
|
188
|
-
[:code,
|
176
|
+
[:code, CollectText.new.call(body) + "\n"]
|
189
177
|
end
|
190
178
|
end
|
191
179
|
|
@@ -194,6 +182,7 @@ module Slim
|
|
194
182
|
register :textile, InterpolateTiltEngine
|
195
183
|
register :rdoc, InterpolateTiltEngine
|
196
184
|
register :creole, InterpolateTiltEngine
|
185
|
+
register :wiki, InterpolateTiltEngine
|
197
186
|
|
198
187
|
# These engines are executed at compile time
|
199
188
|
register :coffee, TagEngine, :tag => :script, :attributes => { :type => 'text/javascript' }, :engine => StaticTiltEngine
|
@@ -203,15 +192,9 @@ module Slim
|
|
203
192
|
|
204
193
|
# These engines are precompiled, code is embedded
|
205
194
|
register :erb, ERBEngine
|
206
|
-
register :haml, PrecompiledTiltEngine
|
207
195
|
register :nokogiri, PrecompiledTiltEngine
|
208
196
|
register :builder, PrecompiledTiltEngine
|
209
197
|
|
210
|
-
# These engines are completely executed at runtime (Usage not recommended, no caching!)
|
211
|
-
register :liquid, DynamicTiltEngine
|
212
|
-
register :radius, DynamicTiltEngine
|
213
|
-
register :markaby, DynamicTiltEngine
|
214
|
-
|
215
198
|
# Embedded javascript/css
|
216
199
|
register :javascript, TagEngine, :tag => :script, :attributes => { :type => 'text/javascript' }
|
217
200
|
register :css, TagEngine, :tag => :style, :attributes => { :type => 'text/css' }
|
data/lib/slim/interpolation.rb
CHANGED
@@ -12,7 +12,7 @@ module Slim
|
|
12
12
|
# Interpolate variables in text (#{variable}).
|
13
13
|
# Split the text into multiple dynamic and static parts.
|
14
14
|
block = [:multi]
|
15
|
-
|
15
|
+
begin
|
16
16
|
case string
|
17
17
|
when /\A\\#\{/
|
18
18
|
# Escaped interpolation
|
@@ -25,12 +25,12 @@ module Slim
|
|
25
25
|
string, code = parse_expression($')
|
26
26
|
escape = code !~ /\A\{.*\}\Z/
|
27
27
|
block << [:slim, :output, escape, escape ? code : code[1..-2], [:multi]]
|
28
|
-
when /\A([^#]
|
28
|
+
when /\A(#|[^#]*)/
|
29
29
|
# Static text
|
30
30
|
block << [:static, $&]
|
31
31
|
string = $'
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end until string.empty?
|
34
34
|
block
|
35
35
|
end
|
36
36
|
|
data/lib/slim/parser.rb
CHANGED
@@ -217,7 +217,7 @@ module Slim
|
|
217
217
|
@stacks.last << [:newline] << [:slim, :embedded, $1, block]
|
218
218
|
@stacks << block
|
219
219
|
parse_text_block
|
220
|
-
return # Don't append newline
|
220
|
+
return # Don't append newline, this has already been done before
|
221
221
|
when /\Adoctype\s+/i
|
222
222
|
# Found doctype declaration
|
223
223
|
@stacks.last << [:html, :doctype, $'.strip]
|
@@ -263,7 +263,7 @@ module Slim
|
|
263
263
|
end
|
264
264
|
|
265
265
|
@line.slice!(0, text_indent || indent)
|
266
|
-
@stacks.last << [:
|
266
|
+
@stacks.last << [:slim, :interpolate, (text_indent ? "\n" : '') + @line] << [:newline]
|
267
267
|
|
268
268
|
# The indentation of first line of the text block
|
269
269
|
# determines the text base indentation.
|
@@ -292,12 +292,13 @@ module Slim
|
|
292
292
|
@stacks.last << tag
|
293
293
|
|
294
294
|
case @line
|
295
|
-
when /\A\s*=(=?)/
|
295
|
+
when /\A\s*=(=?)('?)/
|
296
296
|
# Handle output code
|
297
297
|
block = [:multi]
|
298
298
|
@line = $'
|
299
299
|
content = [:slim, :output, $1 != '=', parse_broken_line, block]
|
300
300
|
tag << content
|
301
|
+
@stacks.last << [:static, ' '] unless $2.empty?
|
301
302
|
@stacks << block
|
302
303
|
when /\A\s*\//
|
303
304
|
# Closed tag. Do nothing
|
data/lib/slim/template.rb
CHANGED
data/lib/slim/version.rb
CHANGED
data/slim.gemspec
CHANGED
@@ -19,15 +19,13 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = %w(lib)
|
21
21
|
|
22
|
-
s.add_runtime_dependency('temple', ['~> 0.3.
|
22
|
+
s.add_runtime_dependency('temple', ['~> 0.3.4'])
|
23
23
|
s.add_runtime_dependency('tilt', ['~> 1.3.2'])
|
24
24
|
|
25
25
|
s.add_development_dependency('rake', ['>= 0.8.7'])
|
26
|
-
s.add_development_dependency('haml', ['>= 3.1.0'])
|
27
26
|
s.add_development_dependency('sass', ['>= 3.1.0'])
|
28
27
|
s.add_development_dependency('minitest', ['>= 0'])
|
29
|
-
s.add_development_dependency('
|
30
|
-
s.add_development_dependency('liquid', ['>= 0'])
|
28
|
+
s.add_development_dependency('kramdown', ['>= 0'])
|
31
29
|
s.add_development_dependency('yard', ['>= 0'])
|
32
30
|
s.add_development_dependency('creole', ['>= 0'])
|
33
31
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class SlimController < ApplicationController
|
2
|
-
def normal
|
2
|
+
def normal
|
3
|
+
end
|
3
4
|
|
4
5
|
def no_layout
|
5
6
|
render :layout => false
|
@@ -9,7 +10,13 @@ class SlimController < ApplicationController
|
|
9
10
|
@hello = "Hello Slim with variables!"
|
10
11
|
end
|
11
12
|
|
12
|
-
def partial
|
13
|
+
def partial
|
14
|
+
end
|
15
|
+
|
16
|
+
def streaming
|
17
|
+
@hello = "Hello Streaming!"
|
18
|
+
render :content_for, :stream => true
|
19
|
+
end
|
13
20
|
|
14
21
|
def integers
|
15
22
|
@integer = 1337
|
@@ -1,22 +1,4 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
-
development:
|
4
|
-
adapter: sqlite3
|
5
|
-
database: db/development.sqlite3
|
6
|
-
pool: 5
|
7
|
-
timeout: 5000
|
8
|
-
|
9
|
-
# Warning: The database defined as "test" will be erased and
|
10
|
-
# re-generated from your development database when you run "rake".
|
11
|
-
# Do not set this db to the same as development or production.
|
12
1
|
test:
|
13
2
|
adapter: sqlite3
|
14
|
-
database:
|
15
|
-
pool: 5
|
16
|
-
timeout: 5000
|
3
|
+
database: ':memory:'
|
17
4
|
|
18
|
-
production:
|
19
|
-
adapter: sqlite3
|
20
|
-
database: db/production.sqlite3
|
21
|
-
pool: 5
|
22
|
-
timeout: 5000
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestSlim < ActionController::IntegrationTest
|
4
4
|
test "normal view" do
|
5
5
|
get "slim/normal"
|
6
6
|
assert_response :success
|
@@ -29,6 +29,17 @@ class TestSlimRails < ActionController::IntegrationTest
|
|
29
29
|
assert_html "<h1>Hello Slim!</h1><p>With a partial!</p>"
|
30
30
|
end
|
31
31
|
|
32
|
+
if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 && Object.const_defined?(:Fiber)
|
33
|
+
puts 'Streaming test enabled'
|
34
|
+
test "streaming" do
|
35
|
+
get "slim/streaming"
|
36
|
+
output = "2f\r\n<!DOCTYPE html><html><head><title>Dummy</title>\r\nd\r\n</head><body>\r\n17\r\nHeading set from a view\r\n15\r\n<div class=\"content\">\r\n53\r\n<p>Page content</p><h1><p>Hello Streaming!</p></h1><h2><p>Hello Streaming!</p></h2>\r\n14\r\n</div></body></html>\r\n0\r\n\r\n"
|
37
|
+
assert_equal output, @response.body
|
38
|
+
end
|
39
|
+
else
|
40
|
+
puts 'Streaming test disabled'
|
41
|
+
end
|
42
|
+
|
32
43
|
test "render integers" do
|
33
44
|
get "slim/integers"
|
34
45
|
assert_html "<p>1337</p>"
|
@@ -41,7 +52,7 @@ class TestSlimRails < ActionController::IntegrationTest
|
|
41
52
|
|
42
53
|
test "content_for" do
|
43
54
|
get "slim/content_for"
|
44
|
-
assert_html "
|
55
|
+
assert_html "<p>Page content</p><h1><p>Hello Slim!</p></h1><h2><p>Hello Slim!</p></h2>", :heading => 'Heading set from a view'
|
45
56
|
end
|
46
57
|
|
47
58
|
test "nested_attributes_form" do
|
@@ -60,7 +71,7 @@ class TestSlimRails < ActionController::IntegrationTest
|
|
60
71
|
protected
|
61
72
|
|
62
73
|
def assert_html(expected, options = {})
|
63
|
-
expected = "<!DOCTYPE html><html><head><title>Dummy</title></head><body>#{expected}</body></html>" unless options[:skip_layout]
|
74
|
+
expected = "<!DOCTYPE html><html><head><title>Dummy</title></head><body>#{options[:heading]}<div class=\"content\">#{expected}</div></body></html>" unless options[:skip_layout]
|
64
75
|
assert_equal expected, @response.body
|
65
76
|
end
|
66
77
|
end
|
data/test/slim/helper.rb
CHANGED
@@ -39,8 +39,20 @@ class TestSlim < MiniTest::Unit::TestCase
|
|
39
39
|
render(source, options)
|
40
40
|
raise 'Ruby error expected'
|
41
41
|
rescue error => ex
|
42
|
-
ex
|
43
|
-
|
42
|
+
assert_backtrace(ex, from)
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_backtrace(ex, from)
|
46
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
47
|
+
# HACK: Rubinius stack trace sometimes has one entry more
|
48
|
+
if ex.backtrace[0] !~ /^#{Regexp.escape from}:/
|
49
|
+
ex.backtrace[1] =~ /^(.*?:\d+):/
|
50
|
+
assert_equal from, $1
|
51
|
+
end
|
52
|
+
else
|
53
|
+
ex.backtrace[0] =~ /^(.*?:\d+):/
|
54
|
+
assert_equal from, $1
|
55
|
+
end
|
44
56
|
end
|
45
57
|
|
46
58
|
def assert_ruby_syntax_error(from, source, options = {})
|
@@ -19,6 +19,14 @@ p
|
|
19
19
|
assert_html '<p>Hello World from @env </p>', source
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_render_with_trailing_whitespace_after_tag
|
23
|
+
source = %q{
|
24
|
+
p=' hello_world
|
25
|
+
}
|
26
|
+
|
27
|
+
assert_html '<p>Hello World from @env</p> ', source
|
28
|
+
end
|
29
|
+
|
22
30
|
def test_no_escape_render_with_trailing_whitespace
|
23
31
|
source = %q{
|
24
32
|
p
|
@@ -28,6 +36,14 @@ p
|
|
28
36
|
assert_html '<p>Hello World from @env </p>', source
|
29
37
|
end
|
30
38
|
|
39
|
+
def test_no_escape_render_with_trailing_whitespace_after_tag
|
40
|
+
source = %q{
|
41
|
+
p==' hello_world
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_html '<p>Hello World from @env</p> ', source
|
45
|
+
end
|
46
|
+
|
31
47
|
def test_render_with_conditional_call
|
32
48
|
source = %q{
|
33
49
|
p
|
@@ -1,26 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
|
-
begin
|
3
|
-
require('creole/template')
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
2
|
|
7
3
|
class TestSlimEmbeddedEngines < TestSlim
|
8
|
-
def test_render_with_haml
|
9
|
-
source = %q{
|
10
|
-
p
|
11
|
-
- text = 'haml'
|
12
|
-
haml:
|
13
|
-
- passed_from_haml = 'from haml'
|
14
|
-
%b Hello from #{text.upcase}!
|
15
|
-
Second Line!
|
16
|
-
- if true
|
17
|
-
= true
|
18
|
-
= passed_from_haml
|
19
|
-
}
|
20
|
-
|
21
|
-
assert_html "<p><b>Hello from HAML!</b>\nSecond Line!\ntrue\nfrom haml</p>", source
|
22
|
-
end
|
23
|
-
|
24
4
|
def test_render_with_erb
|
25
5
|
source = %q{
|
26
6
|
p
|
@@ -46,7 +26,7 @@ markdown:
|
|
46
26
|
* one
|
47
27
|
* two
|
48
28
|
}
|
49
|
-
assert_html "<h1>Header</h1>\n
|
29
|
+
assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n <li>one</li>\n <li>two</li>\n</ul>\n", source
|
50
30
|
end
|
51
31
|
|
52
32
|
def test_render_with_creole
|
@@ -58,6 +38,15 @@ creole:
|
|
58
38
|
assert_html "<h1>head1</h1><h2>head2</h2>", source
|
59
39
|
end
|
60
40
|
|
41
|
+
def test_render_with_wiki
|
42
|
+
source = %q{
|
43
|
+
wiki:
|
44
|
+
= head1
|
45
|
+
== head2
|
46
|
+
}
|
47
|
+
assert_html "<h1>head1</h1><h2>head2</h2>", source
|
48
|
+
end
|
49
|
+
|
61
50
|
def test_render_with_javascript
|
62
51
|
# Keep the trailing space behind "javascript: "!
|
63
52
|
source = %q{
|
@@ -91,16 +80,6 @@ ruby:
|
|
91
80
|
assert_html '3', source
|
92
81
|
end
|
93
82
|
|
94
|
-
def test_render_with_liquid
|
95
|
-
source = %q{
|
96
|
-
p
|
97
|
-
- text = 'before liquid block'
|
98
|
-
liquid:
|
99
|
-
<span>{{text}}</span>
|
100
|
-
}
|
101
|
-
assert_html "<p><span>before liquid block</span></p>", source
|
102
|
-
end
|
103
|
-
|
104
83
|
def test_render_with_scss
|
105
84
|
source = %q{
|
106
85
|
scss:
|
@@ -273,17 +273,17 @@ p(id="marvin" class="martian" data-info="Illudium Q-36")= output_number
|
|
273
273
|
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
274
274
|
end
|
275
275
|
|
276
|
-
def
|
276
|
+
def test_static_empty_attribute
|
277
277
|
source = %q{
|
278
278
|
p(id="marvin" class="" data-info="Illudium Q-36")= output_number
|
279
279
|
}
|
280
280
|
|
281
|
-
assert_html '<p data-info="Illudium Q-36" id="marvin">1337</p>', source
|
281
|
+
assert_html '<p class="" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
282
282
|
end
|
283
283
|
|
284
284
|
def test_dynamic_empty_attribute
|
285
285
|
source = %q{
|
286
|
-
p(id="marvin" class=nil data-info="Illudium Q-36")= output_number
|
286
|
+
p(id="marvin" class=nil other_empty=("".to_s) data-info="Illudium Q-36")= output_number
|
287
287
|
}
|
288
288
|
|
289
289
|
assert_html '<p data-info="Illudium Q-36" id="marvin">1337</p>', source
|
data/test/slim/test_pretty.rb
CHANGED
@@ -15,6 +15,16 @@ doctype 5
|
|
15
15
|
html
|
16
16
|
head
|
17
17
|
title Hello World!
|
18
|
+
/! Meta tags
|
19
|
+
with long explanatory
|
20
|
+
multiline comment
|
21
|
+
meta name="description" content="template language"
|
22
|
+
/! Stylesheets
|
23
|
+
link href="style.css" media="screen" rel="stylesheet" type="text/css"
|
24
|
+
link href="colors.css" media="screen" rel="stylesheet" type="text/css"
|
25
|
+
/! Javascripts
|
26
|
+
script src="jquery.js"
|
27
|
+
script src="jquery.ui.js"
|
18
28
|
sass:
|
19
29
|
body
|
20
30
|
background-color: red
|
@@ -29,6 +39,16 @@ html
|
|
29
39
|
<html>
|
30
40
|
<head>
|
31
41
|
<title>Hello World!</title>
|
42
|
+
<!--Meta tags
|
43
|
+
with long explanatory
|
44
|
+
multiline comment-->
|
45
|
+
<meta content="template language" name="description" />
|
46
|
+
<!--Stylesheets-->
|
47
|
+
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
|
48
|
+
<link href="colors.css" media="screen" rel="stylesheet" type="text/css" />
|
49
|
+
<!--Javascripts-->
|
50
|
+
<script src="jquery.js"></script>
|
51
|
+
<script src="jquery.ui.js"></script>
|
32
52
|
<style type="text/css">
|
33
53
|
body {
|
34
54
|
background-color: red;
|
@@ -94,7 +94,7 @@ p Text line 1
|
|
94
94
|
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
95
95
|
end
|
96
96
|
|
97
|
-
def
|
97
|
+
def test_embedded_ruby1
|
98
98
|
source = %q{
|
99
99
|
ruby:
|
100
100
|
a = 1
|
@@ -106,6 +106,16 @@ ruby:
|
|
106
106
|
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_embedded_ruby2
|
110
|
+
source = %q{
|
111
|
+
ruby:
|
112
|
+
a = 1
|
113
|
+
unknown_ruby_method
|
114
|
+
}
|
115
|
+
|
116
|
+
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
117
|
+
end
|
118
|
+
|
109
119
|
def test_embedded_markdown
|
110
120
|
source = %q{
|
111
121
|
markdown:
|
@@ -118,19 +128,6 @@ markdown:
|
|
118
128
|
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
119
129
|
end
|
120
130
|
|
121
|
-
def test_embedded_liquid
|
122
|
-
source = %q{
|
123
|
-
- text = 'before liquid block'
|
124
|
-
liquid:
|
125
|
-
First
|
126
|
-
{{text}}
|
127
|
-
Third
|
128
|
-
= unknown_ruby_method
|
129
|
-
}
|
130
|
-
|
131
|
-
assert_ruby_error NameError,"(__TEMPLATE__):7", source
|
132
|
-
end
|
133
|
-
|
134
131
|
def test_embedded_javascript
|
135
132
|
source = %q{
|
136
133
|
javascript:
|
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
class ::MockError < NameError
|
4
4
|
end
|
5
5
|
|
6
|
-
class TestSlimTemplate <
|
6
|
+
class TestSlimTemplate < TestSlim
|
7
7
|
class Scope
|
8
8
|
end
|
9
9
|
|
@@ -40,10 +40,9 @@ class TestSlimTemplate < MiniTest::Unit::TestCase
|
|
40
40
|
begin
|
41
41
|
template.render
|
42
42
|
fail 'should have raised an exception'
|
43
|
-
rescue =>
|
44
|
-
assert_kind_of NameError,
|
45
|
-
|
46
|
-
assert_equal 'test.slim', line.split(":").first
|
43
|
+
rescue => ex
|
44
|
+
assert_kind_of NameError, ex
|
45
|
+
assert_backtrace(ex, 'test.slim:12')
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
@@ -53,10 +52,9 @@ class TestSlimTemplate < MiniTest::Unit::TestCase
|
|
53
52
|
template = Slim::Template.new('test.slim') { data }
|
54
53
|
begin
|
55
54
|
res = template.render(Object.new, :name => 'Joe', :foo => 'bar')
|
56
|
-
rescue =>
|
57
|
-
assert_kind_of MockError,
|
58
|
-
|
59
|
-
assert_equal 'test.slim', line.split(":").first
|
55
|
+
rescue => ex
|
56
|
+
assert_kind_of MockError, ex
|
57
|
+
assert_backtrace(ex, 'test.slim:4')
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
@@ -66,7 +64,6 @@ class TestSlimTemplate < MiniTest::Unit::TestCase
|
|
66
64
|
method = template.send(:compiled_method, [])
|
67
65
|
assert_kind_of UnboundMethod, method
|
68
66
|
end
|
69
|
-
|
70
67
|
|
71
68
|
def test_passing_locals
|
72
69
|
template = Slim::Template.new { "p = 'Hey ' + name + '!'\n" }
|
@@ -85,17 +82,16 @@ class TestSlimTemplate < MiniTest::Unit::TestCase
|
|
85
82
|
assert_equal "<p>Hey Joe!</p>", template.render(Scope.new) { 'Joe' }
|
86
83
|
end
|
87
84
|
|
88
|
-
def
|
85
|
+
def test_backtrace_file_and_line_reporting_without_locals
|
89
86
|
data = File.read(__FILE__).split("\n__END__\n").last
|
90
87
|
fail unless data[0] == ?h
|
91
88
|
template = Slim::Template.new('test.slim', 10) { data }
|
92
89
|
begin
|
93
90
|
template.render(Scope.new)
|
94
91
|
fail 'should have raised an exception'
|
95
|
-
rescue =>
|
96
|
-
assert_kind_of NameError,
|
97
|
-
|
98
|
-
assert_equal 'test.slim', line.split(":").first
|
92
|
+
rescue => ex
|
93
|
+
assert_kind_of NameError, ex
|
94
|
+
assert_backtrace(ex, 'test.slim:12')
|
99
95
|
end
|
100
96
|
end
|
101
97
|
|
@@ -105,10 +101,9 @@ class TestSlimTemplate < MiniTest::Unit::TestCase
|
|
105
101
|
template = Slim::Template.new('test.slim') { data }
|
106
102
|
begin
|
107
103
|
res = template.render(Scope.new, :name => 'Joe', :foo => 'bar')
|
108
|
-
rescue =>
|
109
|
-
assert_kind_of MockError,
|
110
|
-
|
111
|
-
assert_equal 'test.slim', line.split(":").first
|
104
|
+
rescue => ex
|
105
|
+
assert_kind_of MockError, ex
|
106
|
+
assert_backtrace(ex, 'test.slim:5')
|
112
107
|
end
|
113
108
|
end
|
114
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,23 +11,23 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-08
|
14
|
+
date: 2011-10-08 00:00:00.000000000 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: temple
|
19
|
-
requirement: &
|
19
|
+
requirement: &2153286200 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.3.
|
24
|
+
version: 0.3.4
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *2153286200
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: tilt
|
30
|
-
requirement: &
|
30
|
+
requirement: &2153285680 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: 1.3.2
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *2153285680
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
41
|
-
requirement: &
|
41
|
+
requirement: &2153285200 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,21 +46,10 @@ dependencies:
|
|
46
46
|
version: 0.8.7
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: haml
|
52
|
-
requirement: &2161717960 !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
|
-
requirements:
|
55
|
-
- - ! '>='
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 3.1.0
|
58
|
-
type: :development
|
59
|
-
prerelease: false
|
60
|
-
version_requirements: *2161717960
|
49
|
+
version_requirements: *2153285200
|
61
50
|
- !ruby/object:Gem::Dependency
|
62
51
|
name: sass
|
63
|
-
requirement: &
|
52
|
+
requirement: &2153284720 !ruby/object:Gem::Requirement
|
64
53
|
none: false
|
65
54
|
requirements:
|
66
55
|
- - ! '>='
|
@@ -68,21 +57,10 @@ dependencies:
|
|
68
57
|
version: 3.1.0
|
69
58
|
type: :development
|
70
59
|
prerelease: false
|
71
|
-
version_requirements: *
|
60
|
+
version_requirements: *2153284720
|
72
61
|
- !ruby/object:Gem::Dependency
|
73
62
|
name: minitest
|
74
|
-
requirement: &
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ! '>='
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '0'
|
80
|
-
type: :development
|
81
|
-
prerelease: false
|
82
|
-
version_requirements: *2152312820
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rdiscount
|
85
|
-
requirement: &2152312340 !ruby/object:Gem::Requirement
|
63
|
+
requirement: &2153284240 !ruby/object:Gem::Requirement
|
86
64
|
none: false
|
87
65
|
requirements:
|
88
66
|
- - ! '>='
|
@@ -90,10 +68,10 @@ dependencies:
|
|
90
68
|
version: '0'
|
91
69
|
type: :development
|
92
70
|
prerelease: false
|
93
|
-
version_requirements: *
|
71
|
+
version_requirements: *2153284240
|
94
72
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
96
|
-
requirement: &
|
73
|
+
name: kramdown
|
74
|
+
requirement: &2153283760 !ruby/object:Gem::Requirement
|
97
75
|
none: false
|
98
76
|
requirements:
|
99
77
|
- - ! '>='
|
@@ -101,10 +79,10 @@ dependencies:
|
|
101
79
|
version: '0'
|
102
80
|
type: :development
|
103
81
|
prerelease: false
|
104
|
-
version_requirements: *
|
82
|
+
version_requirements: *2153283760
|
105
83
|
- !ruby/object:Gem::Dependency
|
106
84
|
name: yard
|
107
|
-
requirement: &
|
85
|
+
requirement: &2153283280 !ruby/object:Gem::Requirement
|
108
86
|
none: false
|
109
87
|
requirements:
|
110
88
|
- - ! '>='
|
@@ -112,10 +90,10 @@ dependencies:
|
|
112
90
|
version: '0'
|
113
91
|
type: :development
|
114
92
|
prerelease: false
|
115
|
-
version_requirements: *
|
93
|
+
version_requirements: *2153283280
|
116
94
|
- !ruby/object:Gem::Dependency
|
117
95
|
name: creole
|
118
|
-
requirement: &
|
96
|
+
requirement: &2153282800 !ruby/object:Gem::Requirement
|
119
97
|
none: false
|
120
98
|
requirements:
|
121
99
|
- - ! '>='
|
@@ -123,10 +101,10 @@ dependencies:
|
|
123
101
|
version: '0'
|
124
102
|
type: :development
|
125
103
|
prerelease: false
|
126
|
-
version_requirements: *
|
104
|
+
version_requirements: *2153282800
|
127
105
|
- !ruby/object:Gem::Dependency
|
128
106
|
name: rcov
|
129
|
-
requirement: &
|
107
|
+
requirement: &2153282280 !ruby/object:Gem::Requirement
|
130
108
|
none: false
|
131
109
|
requirements:
|
132
110
|
- - ! '>='
|
@@ -134,7 +112,7 @@ dependencies:
|
|
134
112
|
version: '0'
|
135
113
|
type: :development
|
136
114
|
prerelease: false
|
137
|
-
version_requirements: *
|
115
|
+
version_requirements: *2153282280
|
138
116
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
139
117
|
parts without becoming cryptic.
|
140
118
|
email:
|
@@ -218,7 +196,7 @@ files:
|
|
218
196
|
- test/rails/db/migrate/20101220223037_parents_and_children.rb
|
219
197
|
- test/rails/script/rails
|
220
198
|
- test/rails/test/helper.rb
|
221
|
-
- test/rails/test/
|
199
|
+
- test/rails/test/test_slim.rb
|
222
200
|
- test/slim/helper.rb
|
223
201
|
- test/slim/test_chain_manipulation.rb
|
224
202
|
- test/slim/test_code_blocks.rb
|