slim 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -2
- data/CHANGES +7 -0
- data/README.md +14 -0
- data/Rakefile +4 -4
- data/benchmarks/context.rb +11 -0
- data/benchmarks/profile-parser.rb +10 -0
- data/benchmarks/profile-render.rb +12 -0
- data/benchmarks/{run.rb → run-benchmarks.rb} +34 -36
- data/benchmarks/{complex.erb → view.erb} +0 -0
- data/benchmarks/{complex.haml → view.haml} +0 -0
- data/benchmarks/{complex.slim → view.slim} +0 -0
- data/lib/slim/embedded_engine.rb +2 -2
- data/lib/slim/engine.rb +7 -5
- data/lib/slim/parser.rb +30 -28
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -3
- data/test/slim/test_encoding.rb +9 -0
- data/test/slim/test_html_structure.rb +24 -0
- data/test/slim/test_parser_errors.rb +20 -0
- data/test/slim/test_ruby_errors.rb +16 -0
- metadata +28 -35
- data/benchmarks/complex_view.rb +0 -15
data/.travis.yml
CHANGED
@@ -9,8 +9,8 @@ env:
|
|
9
9
|
- "TASK=test"
|
10
10
|
- "TASK=test TEMPLE=master"
|
11
11
|
- "TASK=test:rails RAILS=master"
|
12
|
-
- "TASK=test:rails RAILS=3.0.
|
13
|
-
- "TASK=test:rails RAILS=3.1.
|
12
|
+
- "TASK=test:rails RAILS=3.0.11"
|
13
|
+
- "TASK=test:rails RAILS=3.1.3"
|
14
14
|
script: "bundle exec rake test:ci"
|
15
15
|
notifications:
|
16
16
|
email: false
|
data/CHANGES
CHANGED
data/README.md
CHANGED
@@ -208,6 +208,20 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
208
208
|
div class="content"
|
209
209
|
= show_content
|
210
210
|
|
211
|
+
### Inline tags
|
212
|
+
|
213
|
+
Sometimes you may want to be a little more compact and inline the tags.
|
214
|
+
|
215
|
+
ul
|
216
|
+
li.first: a href="/a" A link
|
217
|
+
li: a href="/b" B link
|
218
|
+
|
219
|
+
For readability, don't forget you can wrap the attributes.
|
220
|
+
|
221
|
+
ul
|
222
|
+
li.first: a[href="/a"] A link
|
223
|
+
li: a[href="/b"] B link
|
224
|
+
|
211
225
|
### Set an attribute's value with a method
|
212
226
|
|
213
227
|
* Alternative 1: Use parentheses (), {}, []. The code in the parentheses will be evaluated.
|
data/Rakefile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
begin
|
2
2
|
require 'bundler'
|
3
3
|
Bundler::GemHelper.install_tasks
|
4
|
-
rescue Exception
|
4
|
+
rescue Exception
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rake/testtask'
|
8
8
|
|
9
9
|
desc 'Run Slim benchmarks! (default parameters slow=false iterations=1000)'
|
10
10
|
task :bench, :iterations, :slow do
|
11
|
-
ruby('benchmarks/run.rb')
|
11
|
+
ruby('benchmarks/run-benchmarks.rb')
|
12
12
|
end
|
13
13
|
|
14
14
|
Rake::TestTask.new('test') do |t|
|
@@ -36,7 +36,7 @@ begin
|
|
36
36
|
end
|
37
37
|
rescue LoadError
|
38
38
|
task :rcov do
|
39
|
-
abort
|
39
|
+
abort 'RCov is not available. In order to run rcov, you must: gem install rcov'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -47,7 +47,7 @@ begin
|
|
47
47
|
end
|
48
48
|
rescue LoadError
|
49
49
|
task :yard do
|
50
|
-
abort
|
50
|
+
abort 'YARD is not available. In order to run yard, you must: gem install yard'
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'slim'
|
6
|
+
require 'complex_view'
|
7
|
+
|
8
|
+
content = File.read(File.dirname(__FILE__) + '/view.slim')
|
9
|
+
slim = Slim::Template.new { content }
|
10
|
+
view = ComplexView.new
|
11
|
+
|
12
|
+
10000.times { slim.render(view) }
|
@@ -3,26 +3,24 @@
|
|
3
3
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
4
|
|
5
5
|
require 'slim'
|
6
|
-
require '
|
6
|
+
require 'context'
|
7
7
|
|
8
8
|
require 'benchmark'
|
9
|
-
require 'ostruct'
|
10
9
|
require 'erubis'
|
11
10
|
require 'erb'
|
12
11
|
require 'haml'
|
13
|
-
require 'tilt'
|
14
12
|
|
15
13
|
class SlimBenchmarks
|
16
14
|
def initialize(slow, iterations)
|
17
15
|
@iterations = (iterations || 1000).to_i
|
18
16
|
@benches = []
|
19
17
|
|
20
|
-
tpl_erb = File.read(File.dirname(__FILE__) + '/
|
21
|
-
tpl_haml = File.read(File.dirname(__FILE__) + '/
|
22
|
-
tpl_slim = File.read(File.dirname(__FILE__) + '/
|
18
|
+
tpl_erb = File.read(File.dirname(__FILE__) + '/view.erb')
|
19
|
+
tpl_haml = File.read(File.dirname(__FILE__) + '/view.haml')
|
20
|
+
tpl_slim = File.read(File.dirname(__FILE__) + '/view.slim')
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
context = Context.new
|
23
|
+
context_binding = context.instance_eval { binding }
|
26
24
|
|
27
25
|
erb = ERB.new(tpl_erb)
|
28
26
|
erubis = Erubis::Eruby.new(tpl_erb)
|
@@ -37,9 +35,9 @@ class SlimBenchmarks
|
|
37
35
|
tilt_haml_ugly = Tilt::HamlTemplate.new(:format => :html5, :ugly => true){ tpl_haml }
|
38
36
|
tilt_slim = Slim::Template.new { tpl_slim }
|
39
37
|
|
40
|
-
haml.def_method(
|
41
|
-
haml_ugly.def_method(
|
42
|
-
|
38
|
+
haml.def_method(context, :run_haml)
|
39
|
+
haml_ugly.def_method(context, :run_haml_ugly)
|
40
|
+
context.instance_eval %{
|
43
41
|
def run_erb; #{erb.src}; end
|
44
42
|
def run_erubis; #{erubis.src}; end
|
45
43
|
def run_fast_erubis; #{fast_erubis.src}; end
|
@@ -47,33 +45,33 @@ class SlimBenchmarks
|
|
47
45
|
}
|
48
46
|
|
49
47
|
if slow
|
50
|
-
bench('(1) erb') { ERB.new(tpl_erb).result(
|
51
|
-
bench('(1) erubis') { Erubis::Eruby.new(tpl_erb).result(
|
52
|
-
bench('(1) fast erubis') { Erubis::Eruby.new(tpl_erb).result(
|
53
|
-
bench('(1) slim') { Slim::Template.new { tpl_slim }.render(
|
54
|
-
bench('(1) haml') { Haml::Engine.new(tpl_haml, :format => :html5).render(
|
55
|
-
bench('(1) haml ugly') { Haml::Engine.new(tpl_haml, :format => :html5, :ugly => true).render(
|
48
|
+
bench('(1) erb') { ERB.new(tpl_erb).result(context_binding) }
|
49
|
+
bench('(1) erubis') { Erubis::Eruby.new(tpl_erb).result(context_binding) }
|
50
|
+
bench('(1) fast erubis') { Erubis::Eruby.new(tpl_erb).result(context_binding) }
|
51
|
+
bench('(1) slim') { Slim::Template.new { tpl_slim }.render(context) }
|
52
|
+
bench('(1) haml') { Haml::Engine.new(tpl_haml, :format => :html5).render(context) }
|
53
|
+
bench('(1) haml ugly') { Haml::Engine.new(tpl_haml, :format => :html5, :ugly => true).render(context) }
|
56
54
|
end
|
57
55
|
|
58
|
-
bench('(2) erb') { erb.result(
|
59
|
-
bench('(2) erubis') { erubis.result(
|
60
|
-
bench('(2) fast erubis') { fast_erubis.result(
|
61
|
-
bench('(2) slim') { slim.render(
|
62
|
-
bench('(2) haml') { haml.render(
|
63
|
-
bench('(2) haml ugly') { haml_ugly.render(
|
64
|
-
|
65
|
-
bench('(3) erb') {
|
66
|
-
bench('(3) erubis') {
|
67
|
-
bench('(3) fast erubis') {
|
68
|
-
bench('(3) slim') {
|
69
|
-
bench('(3) haml') {
|
70
|
-
bench('(3) haml ugly') {
|
71
|
-
|
72
|
-
bench('(4) erb') { tilt_erb.render(
|
73
|
-
bench('(4) erubis') { tilt_erubis.render(
|
74
|
-
bench('(4) slim') { tilt_slim.render(
|
75
|
-
bench('(4) haml') { tilt_haml.render(
|
76
|
-
bench('(4) haml ugly') { tilt_haml_ugly.render(
|
56
|
+
bench('(2) erb') { erb.result(context_binding) }
|
57
|
+
bench('(2) erubis') { erubis.result(context_binding) }
|
58
|
+
bench('(2) fast erubis') { fast_erubis.result(context_binding) }
|
59
|
+
bench('(2) slim') { slim.render(context) }
|
60
|
+
bench('(2) haml') { haml.render(context) }
|
61
|
+
bench('(2) haml ugly') { haml_ugly.render(context) }
|
62
|
+
|
63
|
+
bench('(3) erb') { context.run_erb }
|
64
|
+
bench('(3) erubis') { context.run_erubis }
|
65
|
+
bench('(3) fast erubis') { context.run_fast_erubis }
|
66
|
+
bench('(3) slim') { context.run_slim }
|
67
|
+
bench('(3) haml') { context.run_haml }
|
68
|
+
bench('(3) haml ugly') { context.run_haml_ugly }
|
69
|
+
|
70
|
+
bench('(4) erb') { tilt_erb.render(context) }
|
71
|
+
bench('(4) erubis') { tilt_erubis.render(context) }
|
72
|
+
bench('(4) slim') { tilt_slim.render(context) }
|
73
|
+
bench('(4) haml') { tilt_haml.render(context) }
|
74
|
+
bench('(4) haml ugly') { tilt_haml_ugly.render(context) }
|
77
75
|
end
|
78
76
|
|
79
77
|
def run
|
File without changes
|
File without changes
|
File without changes
|
data/lib/slim/embedded_engine.rb
CHANGED
@@ -153,7 +153,7 @@ module Slim
|
|
153
153
|
# ERB engine (uses the Temple ERB implementation)
|
154
154
|
class ERBEngine < EmbeddedEngine
|
155
155
|
def on_slim_embedded(engine, body)
|
156
|
-
Temple::ERB::Parser.new.call(CollectText.new.call(body))
|
156
|
+
[:multi, [:newline], Temple::ERB::Parser.new.call(CollectText.new.call(body))]
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -169,7 +169,7 @@ module Slim
|
|
169
169
|
# Embeds ruby code
|
170
170
|
class RubyEngine < EmbeddedEngine
|
171
171
|
def on_slim_embedded(engine, body)
|
172
|
-
[:code, CollectText.new.call(body)
|
172
|
+
[:multi, [:newline], [:code, CollectText.new.call(body)]]
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
data/lib/slim/engine.rb
CHANGED
@@ -33,7 +33,9 @@ module Slim
|
|
33
33
|
# Symbol | :format | :xhtml | HTML output format
|
34
34
|
# String | :attr_wrapper | '"' | Character to wrap attributes in html (can be ' or ")
|
35
35
|
# Hash | :attr_delimiter | {'class' => ' '} | Joining character used if multiple html attributes are supplied (e.g. id1_id2)
|
36
|
+
# Symbol | :sort_attrs | true | Sort attributes by name
|
36
37
|
# Boolean | :pretty | false | Pretty html indenting (This is slower!)
|
38
|
+
# String | :indent | ' ' | Indentation string
|
37
39
|
# Boolean | :streaming | false (true in Rails > 3.1) | Enable output streaming
|
38
40
|
# Class | :generator | ArrayBuffer/RailsOutputBuffer | Temple code generator (default generator generates array buffer)
|
39
41
|
#
|
@@ -59,13 +61,13 @@ module Slim
|
|
59
61
|
use Slim::Sections, :sections, :dictionary, :dictionary_access
|
60
62
|
use Slim::EndInserter
|
61
63
|
use Slim::Compiler, :disable_capture, :attr_delimiter
|
62
|
-
use Temple::HTML::AttributeMerger, :attr_delimiter
|
63
|
-
use Temple::HTML::Pretty, :format, :attr_wrapper, :pretty
|
64
|
+
use Temple::HTML::AttributeMerger, :attr_delimiter, :sort_attrs
|
65
|
+
use Temple::HTML::Pretty, :format, :attr_wrapper, :pretty, :indent
|
64
66
|
filter :Escapable, :use_html_safe, :disable_escape
|
65
67
|
filter :ControlFlow
|
66
68
|
filter :MultiFlattener
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
use(:Optimizer) { (options[:streaming] ? Temple::Filters::StaticMerger :
|
70
|
+
Temple::Filters::DynamicInliner).new }
|
71
|
+
use(:Generator) { options[:generator].new(options) }
|
70
72
|
end
|
71
73
|
end
|
data/lib/slim/parser.rb
CHANGED
@@ -42,7 +42,7 @@ module Slim
|
|
42
42
|
def call(str)
|
43
43
|
# Set string encoding if option is set
|
44
44
|
if options[:encoding] && str.respond_to?(:encoding)
|
45
|
-
|
45
|
+
old_enc = str.encoding
|
46
46
|
str = str.dup if str.frozen?
|
47
47
|
str.force_encoding(options[:encoding])
|
48
48
|
# Fall back to old encoding if new encoding is invalid
|
@@ -73,12 +73,8 @@ module Slim
|
|
73
73
|
|
74
74
|
DELIMITER_REGEX = /\A[\(\[\{]/
|
75
75
|
ATTR_NAME_REGEX = '\A\s*(\w[:\w-]*)'
|
76
|
-
|
77
|
-
|
78
|
-
CLASS_ID_REGEX = /\A(#|\.)([\w\u00c0-\uFFFF][\w:\u00c0-\uFFFF-]*)/
|
79
|
-
else
|
80
|
-
CLASS_ID_REGEX = /\A(#|\.)(\w[\w:-]*)/
|
81
|
-
end
|
76
|
+
CLASS_ID_REGEX = /\A(#|\.)(\w[\w-]*\w|\w+)/
|
77
|
+
TAG_REGEX = /\A([#\.]|\w[\w:-]*\w|\w+)/
|
82
78
|
|
83
79
|
def reset(lines = nil, stacks = nil)
|
84
80
|
# Since you can indent however you like in Slim, we need to keep a list
|
@@ -175,11 +171,7 @@ module Slim
|
|
175
171
|
# Found a comment block.
|
176
172
|
if @line =~ %r{\A/!( ?)(.*)\Z}
|
177
173
|
# HTML comment
|
178
|
-
|
179
|
-
@stacks.last << [:html, :comment, block]
|
180
|
-
@stacks << block
|
181
|
-
@stacks.last << [:slim, :interpolate, $2] unless $2.empty?
|
182
|
-
parse_text_block($2.empty? ? nil : @indents.last + $1.size + 2)
|
174
|
+
@stacks.last << [:html, :comment, parse_text_block($2, @indents.last + $1.size + 2)]
|
183
175
|
elsif @line =~ %r{\A/\[\s*(.*?)\s*\]\s*\Z}
|
184
176
|
# HTML conditional comment
|
185
177
|
block = [:multi]
|
@@ -192,8 +184,7 @@ module Slim
|
|
192
184
|
when /\A([\|'])( ?)(.*)\Z/
|
193
185
|
# Found a text block.
|
194
186
|
trailing_ws = $1 == "'"
|
195
|
-
@stacks.last <<
|
196
|
-
parse_text_block($3.empty? ? nil : @indents.last + $2.size + 1)
|
187
|
+
@stacks.last << parse_text_block($3, @indents.last + $2.size + 1)
|
197
188
|
@stacks.last << [:static, ' '] if trailing_ws
|
198
189
|
when /\A-/
|
199
190
|
# Found a code block.
|
@@ -213,15 +204,11 @@ module Slim
|
|
213
204
|
@stacks << block
|
214
205
|
when /\A(\w+):\s*\Z/
|
215
206
|
# Embedded template detected. It is treated as block.
|
216
|
-
|
217
|
-
@stacks.last << [:newline] << [:slim, :embedded, $1, block]
|
218
|
-
@stacks << block
|
219
|
-
parse_text_block
|
220
|
-
return # Don't append newline, this has already been done before
|
207
|
+
@stacks.last << [:slim, :embedded, $1, parse_text_block]
|
221
208
|
when /\Adoctype\s+/i
|
222
209
|
# Found doctype declaration
|
223
210
|
@stacks.last << [:html, :doctype, $'.strip]
|
224
|
-
when
|
211
|
+
when TAG_REGEX
|
225
212
|
# Found a HTML tag.
|
226
213
|
parse_tag($&)
|
227
214
|
else
|
@@ -237,19 +224,26 @@ module Slim
|
|
237
224
|
end
|
238
225
|
end
|
239
226
|
|
240
|
-
def parse_text_block(text_indent = nil)
|
227
|
+
def parse_text_block(first_line = nil, text_indent = nil)
|
228
|
+
result = [:multi]
|
229
|
+
if !first_line || first_line.empty?
|
230
|
+
text_indent = nil
|
231
|
+
else
|
232
|
+
result << [:slim, :interpolate, first_line]
|
233
|
+
end
|
234
|
+
|
241
235
|
empty_lines = 0
|
242
236
|
until @lines.empty?
|
243
237
|
if @lines.first =~ /\A\s*\Z/
|
244
238
|
next_line
|
245
|
-
|
239
|
+
result << [:newline]
|
246
240
|
empty_lines += 1 if text_indent
|
247
241
|
else
|
248
242
|
indent = get_indent(@lines.first)
|
249
243
|
break if indent <= @indents.last
|
250
244
|
|
251
245
|
if empty_lines > 0
|
252
|
-
|
246
|
+
result << [:slim, :interpolate, "\n" * empty_lines]
|
253
247
|
empty_lines = 0
|
254
248
|
end
|
255
249
|
|
@@ -261,13 +255,14 @@ module Slim
|
|
261
255
|
offset = text_indent ? indent - text_indent : 0
|
262
256
|
syntax_error!('Unexpected text indentation') if offset < 0
|
263
257
|
|
264
|
-
|
258
|
+
result << [:newline] << [:slim, :interpolate, (text_indent ? "\n" : '') + (' ' * offset) + @line]
|
265
259
|
|
266
260
|
# The indentation of first line of the text block
|
267
261
|
# determines the text base indentation.
|
268
262
|
text_indent ||= indent
|
269
263
|
end
|
270
264
|
end
|
265
|
+
result
|
271
266
|
end
|
272
267
|
|
273
268
|
def parse_broken_line
|
@@ -290,6 +285,16 @@ module Slim
|
|
290
285
|
@stacks.last << tag
|
291
286
|
|
292
287
|
case @line
|
288
|
+
when /\A\s*:\s*/
|
289
|
+
# Block expansion
|
290
|
+
@line = $'
|
291
|
+
(@line =~ TAG_REGEX) || syntax_error!('Expected tag')
|
292
|
+
content = [:multi]
|
293
|
+
tag << content
|
294
|
+
i = @stacks.size
|
295
|
+
@stacks << content
|
296
|
+
parse_tag($1)
|
297
|
+
@stacks.delete_at(i)
|
293
298
|
when /\A\s*=(=?)('?)/
|
294
299
|
# Handle output code
|
295
300
|
block = [:multi]
|
@@ -307,10 +312,7 @@ module Slim
|
|
307
312
|
@stacks << content
|
308
313
|
when /\A( ?)(.*)\Z/
|
309
314
|
# Text content
|
310
|
-
|
311
|
-
tag << content
|
312
|
-
@stacks << content
|
313
|
-
parse_text_block(@orig_line.size - @line.size + $1.size)
|
315
|
+
tag << parse_text_block($2, @orig_line.size - @line.size + $1.size)
|
314
316
|
end
|
315
317
|
end
|
316
318
|
|
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.5'])
|
23
23
|
s.add_runtime_dependency('tilt', ['~> 1.3.2'])
|
24
24
|
|
25
25
|
s.add_development_dependency('rake', ['>= 0.8.7'])
|
26
26
|
s.add_development_dependency('sass', ['>= 3.1.0'])
|
27
27
|
s.add_development_dependency('minitest', ['>= 0'])
|
28
28
|
s.add_development_dependency('kramdown', ['>= 0'])
|
29
|
-
s.add_development_dependency('yard', ['>= 0'])
|
30
29
|
s.add_development_dependency('creole', ['>= 0'])
|
31
30
|
s.add_development_dependency('builder', ['>= 0'])
|
32
|
-
#s.add_development_dependency('rcov', ['>= 0'])
|
33
31
|
end
|
@@ -435,4 +435,28 @@ data-info="myinfo">
|
|
435
435
|
end
|
436
436
|
end
|
437
437
|
|
438
|
+
def test_block_expansion_support
|
439
|
+
source = %q{
|
440
|
+
ul
|
441
|
+
li.first: a href='a' foo
|
442
|
+
li: a href='b' bar
|
443
|
+
li.last: a href='c' baz
|
444
|
+
}
|
445
|
+
assert_html %{<ul><li class=\"first\"><a href=\"a\">foo</a></li><li><a href=\"b\">bar</a></li><li class=\"last\"><a href=\"c\">baz</a></li></ul>}, source
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_block_expansion_class_attributes
|
449
|
+
source = %q{
|
450
|
+
.a: .b: #c d
|
451
|
+
}
|
452
|
+
assert_html %{<div class="a"><div class="b"><div id="c">d</div></div></div>}, source
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_block_expansion_nesting
|
456
|
+
source = %q{
|
457
|
+
html: body: .content
|
458
|
+
| Text
|
459
|
+
}
|
460
|
+
assert_html %{<html><body><div class=\"content\">Text</div></body></html>}, source
|
461
|
+
end
|
438
462
|
end
|
@@ -104,4 +104,24 @@ p
|
|
104
104
|
|
105
105
|
assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img src=\n ^\n", source
|
106
106
|
end
|
107
|
+
|
108
|
+
def test_missing_tag_in_block_expansion
|
109
|
+
source = %{
|
110
|
+
html: body:
|
111
|
+
}
|
112
|
+
|
113
|
+
assert_syntax_error "Expected tag\n (__TEMPLATE__), Line 2\n html: body:\n ^\n", source
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_invalid_tag_in_block_expansion
|
117
|
+
source = %{
|
118
|
+
html: body: /comment
|
119
|
+
}
|
120
|
+
assert_syntax_error "Expected tag\n (__TEMPLATE__), Line 2\n html: body: /comment\n ^\n", source
|
121
|
+
|
122
|
+
source = %{
|
123
|
+
html: body:/comment
|
124
|
+
}
|
125
|
+
assert_syntax_error "Expected tag\n (__TEMPLATE__), Line 2\n html: body:/comment\n ^\n", source
|
126
|
+
end
|
107
127
|
end
|
@@ -94,6 +94,22 @@ p Text line 1
|
|
94
94
|
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
95
95
|
end
|
96
96
|
|
97
|
+
def test_embedded_erb
|
98
|
+
source = %q{
|
99
|
+
erb:
|
100
|
+
<%= 123 %>
|
101
|
+
Hello from ERB!
|
102
|
+
<%#
|
103
|
+
comment block
|
104
|
+
%>
|
105
|
+
<% if true %>
|
106
|
+
Text
|
107
|
+
<% end %>
|
108
|
+
= unknown_ruby_method
|
109
|
+
}
|
110
|
+
assert_ruby_error NameError,"(__TEMPLATE__):11", source
|
111
|
+
end
|
112
|
+
|
97
113
|
def test_embedded_ruby1
|
98
114
|
source = %q{
|
99
115
|
ruby:
|
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.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,22 +11,22 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2012-01-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: temple
|
18
|
-
requirement: &
|
18
|
+
requirement: &2152139880 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.3.
|
23
|
+
version: 0.3.5
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2152139880
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tilt
|
29
|
-
requirement: &
|
29
|
+
requirement: &2152135380 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 1.3.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2152135380
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rake
|
40
|
-
requirement: &
|
40
|
+
requirement: &2152133280 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: 0.8.7
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2152133280
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: sass
|
51
|
-
requirement: &
|
51
|
+
requirement: &2152132380 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: 3.1.0
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2152132380
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: minitest
|
62
|
-
requirement: &
|
62
|
+
requirement: &2152131200 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2152131200
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: kramdown
|
73
|
-
requirement: &
|
73
|
+
requirement: &2152129720 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,21 +78,10 @@ dependencies:
|
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: yard
|
84
|
-
requirement: &2160328920 !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: *2160328920
|
81
|
+
version_requirements: *2152129720
|
93
82
|
- !ruby/object:Gem::Dependency
|
94
83
|
name: creole
|
95
|
-
requirement: &
|
84
|
+
requirement: &2152128100 !ruby/object:Gem::Requirement
|
96
85
|
none: false
|
97
86
|
requirements:
|
98
87
|
- - ! '>='
|
@@ -100,10 +89,10 @@ dependencies:
|
|
100
89
|
version: '0'
|
101
90
|
type: :development
|
102
91
|
prerelease: false
|
103
|
-
version_requirements: *
|
92
|
+
version_requirements: *2152128100
|
104
93
|
- !ruby/object:Gem::Dependency
|
105
94
|
name: builder
|
106
|
-
requirement: &
|
95
|
+
requirement: &2152125140 !ruby/object:Gem::Requirement
|
107
96
|
none: false
|
108
97
|
requirements:
|
109
98
|
- - ! '>='
|
@@ -111,7 +100,7 @@ dependencies:
|
|
111
100
|
version: '0'
|
112
101
|
type: :development
|
113
102
|
prerelease: false
|
114
|
-
version_requirements: *
|
103
|
+
version_requirements: *2152125140
|
115
104
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
116
105
|
parts without becoming cryptic.
|
117
106
|
email:
|
@@ -133,11 +122,13 @@ files:
|
|
133
122
|
- LICENSE
|
134
123
|
- README.md
|
135
124
|
- Rakefile
|
136
|
-
- benchmarks/
|
137
|
-
- benchmarks/
|
138
|
-
- benchmarks/
|
139
|
-
- benchmarks/
|
140
|
-
- benchmarks/
|
125
|
+
- benchmarks/context.rb
|
126
|
+
- benchmarks/profile-parser.rb
|
127
|
+
- benchmarks/profile-render.rb
|
128
|
+
- benchmarks/run-benchmarks.rb
|
129
|
+
- benchmarks/view.erb
|
130
|
+
- benchmarks/view.haml
|
131
|
+
- benchmarks/view.slim
|
141
132
|
- bin/slimrb
|
142
133
|
- extra/slim-mode.el
|
143
134
|
- extra/test.slim
|
@@ -204,6 +195,7 @@ files:
|
|
204
195
|
- test/slim/test_code_output.rb
|
205
196
|
- test/slim/test_code_structure.rb
|
206
197
|
- test/slim/test_embedded_engines.rb
|
198
|
+
- test/slim/test_encoding.rb
|
207
199
|
- test/slim/test_html_escaping.rb
|
208
200
|
- test/slim/test_html_structure.rb
|
209
201
|
- test/slim/test_parser_errors.rb
|
@@ -239,3 +231,4 @@ signing_key:
|
|
239
231
|
specification_version: 3
|
240
232
|
summary: Slim is a template language.
|
241
233
|
test_files: []
|
234
|
+
has_rdoc:
|
data/benchmarks/complex_view.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'tilt'
|
2
|
-
|
3
|
-
class ComplexView
|
4
|
-
def header
|
5
|
-
"Colors"
|
6
|
-
end
|
7
|
-
|
8
|
-
def item
|
9
|
-
items = []
|
10
|
-
items << { :name => 'red', :current => true, :url => '#red' }
|
11
|
-
items << { :name => 'green', :current => false, :url => '#green' }
|
12
|
-
items << { :name => 'blue', :current => false, :url => '#blue' }
|
13
|
-
items
|
14
|
-
end
|
15
|
-
end
|