slim 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -3
- data/.travis.yml +17 -0
- data/CHANGES +7 -0
- data/Gemfile +9 -9
- data/README.md +17 -3
- data/Rakefile +15 -11
- data/benchmarks/{src/complex.erb → complex.erb} +0 -0
- data/benchmarks/{src/complex.haml → complex.haml} +0 -0
- data/benchmarks/{src/complex.slim → complex.slim} +0 -0
- data/benchmarks/{src/complex_view.rb → complex_view.rb} +0 -0
- data/benchmarks/run.rb +6 -6
- data/lib/slim/compiler.rb +1 -1
- data/lib/slim/engine.rb +11 -8
- data/lib/slim/parser.rb +28 -10
- data/lib/slim/template.rb +5 -3
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +6 -3
- data/test/{integration/rails/dummy → rails}/Rakefile +0 -0
- data/test/{integration/rails/dummy → rails}/app/controllers/application_controller.rb +0 -0
- data/test/{integration/rails/dummy → rails}/app/controllers/parents_controller.rb +0 -0
- data/test/{integration/rails/dummy → rails}/app/controllers/slim_controller.rb +0 -0
- data/test/{integration/rails/dummy → rails}/app/helpers/application_helper.rb +0 -0
- data/test/{integration/rails/dummy → rails}/app/models/child.rb +1 -3
- data/test/{integration/rails/dummy → rails}/app/models/parent.rb +1 -3
- data/test/{integration/rails/dummy → rails}/app/views/layouts/application.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/parents/_form.html.slim +0 -1
- data/test/{integration/rails/dummy → rails}/app/views/parents/edit.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/parents/new.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/parents/show.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/_partial.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/content_for.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/erb.html.erb +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/integers.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/nil.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/no_layout.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/normal.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/partial.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/app/views/slim/variables.html.slim +0 -0
- data/test/{integration/rails/dummy → rails}/config.ru +0 -0
- data/test/{integration/rails/dummy → rails}/config/application.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/boot.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/database.yml +0 -0
- data/test/{integration/rails/dummy → rails}/config/environment.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/environments/development.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/environments/production.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/environments/test.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/initializers/inflections.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/initializers/mime_types.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/initializers/secret_token.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/initializers/session_store.rb +0 -0
- data/test/{integration/rails/dummy → rails}/config/locales/en.yml +0 -0
- data/test/{integration/rails/dummy → rails}/config/routes.rb +0 -0
- data/test/{integration/rails/dummy → rails}/db/migrate/20101220223037_parents_and_children.rb +0 -0
- data/test/{integration/rails/dummy → rails}/script/rails +0 -0
- data/test/{integration/rails/test_helper.rb → rails/test/helper.rb} +2 -2
- data/test/{integration/rails → rails/test}/test_slim_rails.rb +2 -2
- data/test/{helper.rb → slim/helper.rb} +2 -2
- data/test/slim/test_html_structure.rb +9 -0
- data/test/slim/test_ruby_errors.rb +11 -1
- data/test/slim/test_text_interpolation.rb +8 -0
- metadata +77 -76
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- ruby-head
|
6
|
+
- jruby
|
7
|
+
- rbx-2.0
|
8
|
+
env:
|
9
|
+
- "TASK=test"
|
10
|
+
- "TASK=test TEMPLE=master"
|
11
|
+
- "TASK=test:rails TEMPLE=master RAILS=master"
|
12
|
+
- "TASK=test:rails RAILS=3.0.10"
|
13
|
+
script: "bundle exec rake test:ci"
|
14
|
+
notifications:
|
15
|
+
email: false
|
16
|
+
irc:
|
17
|
+
- "irc.freenode.org#slim-lang"
|
data/CHANGES
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
master
|
2
2
|
|
3
|
+
1.0.2
|
4
|
+
|
5
|
+
* Support for Rails 3.1 streaming (Temple > 0.3.2 required)
|
6
|
+
* Switch to default format xhtml (supports all doctypes, including html5)
|
7
|
+
* Improve parsing of #{interpolation} in quoted attributes (issue #159)
|
8
|
+
* Use travis-ci for continous integration testing
|
9
|
+
|
3
10
|
1.0.1
|
4
11
|
|
5
12
|
* Only delimiting brackets must be balanced in ruby attributes
|
data/Gemfile
CHANGED
@@ -2,15 +2,15 @@ source :rubygems
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
if
|
6
|
-
|
7
|
-
gem 'temple', :git => 'git://github.com/judofyr/temple.git'
|
8
|
-
else
|
9
|
-
gem 'temple', :path => path
|
10
|
-
end
|
5
|
+
if ENV['TEMPLE'] == 'master'
|
6
|
+
gem 'temple', :git => 'git://github.com/judofyr/temple.git'
|
11
7
|
end
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
if ENV['RAILS']
|
10
|
+
if ENV['RAILS'] == 'master'
|
11
|
+
gem 'rails', :git => 'git://github.com/rails/rails.git'
|
12
|
+
else
|
13
|
+
gem 'rails', "= #{ENV['RAILS']}"
|
14
|
+
end
|
15
15
|
gem 'sqlite3-ruby'
|
16
|
-
end
|
16
|
+
end
|
data/README.md
CHANGED
@@ -155,7 +155,7 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
155
155
|
|
156
156
|
If you wrap the attributes, you can spread them across multiple lines:
|
157
157
|
|
158
|
-
h2[ id="tagline"
|
158
|
+
h2[ id="tagline"
|
159
159
|
class="small tagline"] = page_tagline
|
160
160
|
|
161
161
|
### Add content to a tag
|
@@ -290,8 +290,8 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
290
290
|
## Benchmarks
|
291
291
|
|
292
292
|
*The benchmarks are only to demonstrate that Slim's speed should not
|
293
|
-
be a determining factor in your template choice. Even if we don't
|
294
|
-
agree, we'd prefer you to use any other reason for choosing another
|
293
|
+
be a determining factor in your template choice. Even if we don't
|
294
|
+
agree, we'd prefer you to use any other reason for choosing another
|
295
295
|
template language.*
|
296
296
|
|
297
297
|
# Linux + Ruby 1.9.2, 1000 iterations
|
@@ -338,6 +338,20 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
338
338
|
Sinatra, Ramaze and Camping. (Rails still uses its own template
|
339
339
|
compilation.)
|
340
340
|
|
341
|
+
## Tests
|
342
|
+
|
343
|
+
Slim provides an extensive test-suite based on minitest. You can run the tests
|
344
|
+
with 'rake test' and the rails integration tests with 'rake test:rails'.
|
345
|
+
|
346
|
+
Travis-CI is used for continous integration testing: http://travis-ci.org/#!/stonean/slim
|
347
|
+
|
348
|
+
Slim is working well on the following ruby implementations:
|
349
|
+
|
350
|
+
* Ruby 1.8.7
|
351
|
+
* Ruby 1.9.2
|
352
|
+
* Ruby EE
|
353
|
+
* JRuby
|
354
|
+
|
341
355
|
## License
|
342
356
|
|
343
357
|
This project is released under the MIT license.
|
data/Rakefile
CHANGED
@@ -6,28 +6,32 @@ end
|
|
6
6
|
|
7
7
|
require 'rake/testtask'
|
8
8
|
|
9
|
-
desc 'Run Slim benchmarks! (
|
10
|
-
task :bench, :iterations, :slow do
|
11
|
-
ruby(
|
9
|
+
desc 'Run Slim benchmarks! (default parameters slow=false iterations=1000)'
|
10
|
+
task :bench, :iterations, :slow do
|
11
|
+
ruby('benchmarks/run.rb')
|
12
12
|
end
|
13
13
|
|
14
|
-
Rake::TestTask.new(
|
15
|
-
t.libs << 'lib' << 'test'
|
16
|
-
t.
|
14
|
+
Rake::TestTask.new('test') do |t|
|
15
|
+
t.libs << 'lib' << 'test/slim'
|
16
|
+
t.test_files = FileList['test/slim/test_*.rb']
|
17
17
|
t.verbose = true
|
18
18
|
end
|
19
19
|
|
20
|
-
Rake::TestTask.new(:
|
21
|
-
t.libs << 'lib'
|
22
|
-
t.
|
20
|
+
Rake::TestTask.new('test:rails') do |t|
|
21
|
+
t.libs << 'lib'
|
22
|
+
t.test_files = FileList['test/rails/test/test_*.rb']
|
23
23
|
t.verbose = true
|
24
24
|
end
|
25
25
|
|
26
|
+
task 'test:ci' do |t|
|
27
|
+
Rake::Task[ENV['TASK']].execute
|
28
|
+
end
|
29
|
+
|
26
30
|
begin
|
27
31
|
require 'rcov/rcovtask'
|
28
32
|
Rcov::RcovTask.new do |t|
|
29
|
-
t.libs << 'lib' << 'test'
|
30
|
-
t.
|
33
|
+
t.libs << 'lib' << 'test/slim'
|
34
|
+
t.test_files = FileList['test/slim/test_*.rb']
|
31
35
|
t.verbose = true
|
32
36
|
end
|
33
37
|
rescue LoadError
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/benchmarks/run.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
4
|
|
5
5
|
require 'slim'
|
6
6
|
require 'complex_view'
|
@@ -17,9 +17,9 @@ class SlimBenchmarks
|
|
17
17
|
@iterations = (iterations || 1000).to_i
|
18
18
|
@benches = []
|
19
19
|
|
20
|
-
tpl_erb = File.read(File.dirname(__FILE__) + '/
|
21
|
-
tpl_haml = File.read(File.dirname(__FILE__) + '/
|
22
|
-
tpl_slim = File.read(File.dirname(__FILE__) + '/
|
20
|
+
tpl_erb = File.read(File.dirname(__FILE__) + '/complex.erb')
|
21
|
+
tpl_haml = File.read(File.dirname(__FILE__) + '/complex.haml')
|
22
|
+
tpl_slim = File.read(File.dirname(__FILE__) + '/complex.slim')
|
23
23
|
|
24
24
|
view = ComplexView.new
|
25
25
|
eview = OpenStruct.new(:header => view.header, :item => view.item).instance_eval{ binding }
|
@@ -87,7 +87,7 @@ class SlimBenchmarks
|
|
87
87
|
end
|
88
88
|
puts "
|
89
89
|
1. Uncached benchmark. Template is parsed every time.
|
90
|
-
Activate this benchmark with slow=1.
|
90
|
+
Activate this benchmark with 'rake bench slow=1'.
|
91
91
|
|
92
92
|
2. Cached benchmark. Template is parsed before the benchmark.
|
93
93
|
The ruby code generated by the template engine might be evaluated every time.
|
@@ -111,4 +111,4 @@ class SlimBenchmarks
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
SlimBenchmarks.new(
|
114
|
+
SlimBenchmarks.new(ENV['slow'], ENV['iterations']).run
|
data/lib/slim/compiler.rb
CHANGED
data/lib/slim/engine.rb
CHANGED
@@ -10,7 +10,6 @@ module Slim
|
|
10
10
|
# This overwrites some temple default options.
|
11
11
|
set_default_options :pretty => false,
|
12
12
|
:attr_wrapper => '"',
|
13
|
-
:format => :html5,
|
14
13
|
:attr_delimiter => {'class' => ' '},
|
15
14
|
:generator => Temple::Generators::ArrayBuffer
|
16
15
|
|
@@ -21,19 +20,21 @@ module Slim
|
|
21
20
|
# --------------------------------------------------------------------------------------------------------------------------------------------
|
22
21
|
# String | :file | nil | Name of parsed file, set automatically by Slim::Template
|
23
22
|
# Integer | :tabsize | 4 | Number of whitespaces per tab (used by the parser)
|
24
|
-
# String | :encoding | utf-8
|
23
|
+
# String | :encoding | "utf-8" | Set encoding of template
|
24
|
+
# String | :default_tag | "div" | Default tag to be used if tag name is omitted
|
25
25
|
# String list | :enable_engines | All enabled | List of enabled embedded engines (whitelist)
|
26
26
|
# String list | :disable_engines | None disabled | List of disabled embedded engines (blacklist)
|
27
27
|
# Boolean | :sections | false | Enable sections mode (logic-less)
|
28
28
|
# String | :dictionary | "self" | Name of dictionary variable in sections mode
|
29
29
|
# Symbol | :dictionary_access | :wrapped | Access mode of dictionary variable (:wrapped, :symbol, :string)
|
30
|
-
# Boolean | :disable_capture | false (true in Rails) | Disable capturing in blocks (blocks write to the default buffer
|
30
|
+
# Boolean | :disable_capture | false (true in Rails) | Disable capturing in blocks (blocks write to the default buffer
|
31
31
|
# Boolean | :disable_escape | false | Disable automatic escaping of strings
|
32
32
|
# Boolean | :use_html_safe | false (true in Rails) | Use String#html_safe? from ActiveSupport (Works together with :disable_escape)
|
33
|
-
# Symbol | :format | :
|
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
36
|
# Boolean | :pretty | false | Pretty html indenting (This is slower!)
|
37
|
+
# Boolean | :streaming | false (true in Rails > 3.1) | Enable output streaming
|
37
38
|
# Class | :generator | ArrayBuffer/RailsOutputBuffer | Temple code generator (default generator generates array buffer)
|
38
39
|
#
|
39
40
|
# It is also possible to set all options supported by the generator (option :generator). The standard generators
|
@@ -52,17 +53,19 @@ module Slim
|
|
52
53
|
# It is recommended to set the default settings only once in the code and avoid duplication. Only use
|
53
54
|
# `set_default_options` when you have to override some default settings.
|
54
55
|
#
|
55
|
-
use Slim::Parser, :file, :tabsize, :encoding
|
56
|
+
use Slim::Parser, :file, :tabsize, :encoding, :default_tag
|
56
57
|
use Slim::EmbeddedEngine, :enable_engines, :disable_engines, :pretty
|
57
58
|
use Slim::Interpolation
|
58
59
|
use Slim::Sections, :sections, :dictionary, :dictionary_access
|
59
60
|
use Slim::EndInserter
|
60
61
|
use Slim::Compiler, :disable_capture, :attr_delimiter
|
61
|
-
use Temple::HTML::
|
62
|
+
use Temple::HTML::AttributeMerger, :attr_delimiter
|
63
|
+
use Temple::HTML::Pretty, :format, :attr_wrapper, :pretty
|
62
64
|
filter :Escapable, :use_html_safe, :disable_escape
|
63
65
|
filter :ControlFlow
|
64
66
|
filter :MultiFlattener
|
65
|
-
|
66
|
-
|
67
|
+
wildcard(:Optimizer) { (options[:streaming] ? Temple::Filters::StaticMerger :
|
68
|
+
Temple::Filters::DynamicInliner).new }
|
69
|
+
wildcard(:Generator) { options[:generator].new(options) }
|
67
70
|
end
|
68
71
|
end
|
data/lib/slim/parser.rb
CHANGED
@@ -5,7 +5,8 @@ module Slim
|
|
5
5
|
include Temple::Mixins::Options
|
6
6
|
|
7
7
|
set_default_options :tabsize => 4,
|
8
|
-
:encoding => 'utf-8'
|
8
|
+
:encoding => 'utf-8',
|
9
|
+
:default_tag => 'div'
|
9
10
|
|
10
11
|
class SyntaxError < StandardError
|
11
12
|
attr_reader :error, :file, :line, :lineno, :column
|
@@ -72,7 +73,6 @@ module Slim
|
|
72
73
|
|
73
74
|
DELIMITER_REGEX = /\A[\(\[\{]/
|
74
75
|
ATTR_NAME_REGEX = '\A\s*(\w[:\w-]*)'
|
75
|
-
QUOTED_VALUE_REGEX = /\A("[^"]*"|'[^']*')/
|
76
76
|
|
77
77
|
if RUBY_VERSION > '1.9'
|
78
78
|
CLASS_ID_REGEX = /\A(#|\.)([\w\u00c0-\uFFFF][\w:\u00c0-\uFFFF-]*)/
|
@@ -283,7 +283,7 @@ module Slim
|
|
283
283
|
|
284
284
|
def parse_tag(tag)
|
285
285
|
if tag == '#' || tag == '.'
|
286
|
-
tag =
|
286
|
+
tag = options[:default_tag]
|
287
287
|
else
|
288
288
|
@line.slice!(0, tag.size)
|
289
289
|
end
|
@@ -343,10 +343,10 @@ module Slim
|
|
343
343
|
name = $1
|
344
344
|
if delimiter && $2 != '='
|
345
345
|
attributes << [:slim, :attr, name, false, 'true']
|
346
|
-
elsif @line =~
|
346
|
+
elsif @line =~ /\A["']/
|
347
347
|
# Value is quoted (static)
|
348
348
|
@line = $'
|
349
|
-
attributes << [:html, :attr, name, [:slim, :interpolate,
|
349
|
+
attributes << [:html, :attr, name, [:slim, :interpolate, parse_quoted_attribute($&)]]
|
350
350
|
else
|
351
351
|
# Value is ruby code
|
352
352
|
escape = @line[0] != ?=
|
@@ -380,11 +380,7 @@ module Slim
|
|
380
380
|
end
|
381
381
|
|
382
382
|
def parse_ruby_attribute(outer_delimiter)
|
383
|
-
|
384
|
-
count, delimiter, close_delimiter = 0, nil, nil
|
385
|
-
|
386
|
-
# Attribute value buffer
|
387
|
-
value = ''
|
383
|
+
value, count, delimiter, close_delimiter = '', 0, nil, nil
|
388
384
|
|
389
385
|
# Attribute ends with space or attribute delimiter
|
390
386
|
end_regex = /\A[\s#{Regexp.escape outer_delimiter.to_s}]/
|
@@ -414,6 +410,28 @@ module Slim
|
|
414
410
|
value
|
415
411
|
end
|
416
412
|
|
413
|
+
def parse_quoted_attribute(quote)
|
414
|
+
value, count = '', 0
|
415
|
+
|
416
|
+
until @line.empty? || (count == 0 && @line[0] == quote[0])
|
417
|
+
if count > 0
|
418
|
+
if @line[0] == ?{
|
419
|
+
count += 1
|
420
|
+
elsif @line[0] == ?}
|
421
|
+
count -= 1
|
422
|
+
end
|
423
|
+
elsif @line =~ /\A#\{/
|
424
|
+
value << @line.slice!(0)
|
425
|
+
count = 1
|
426
|
+
end
|
427
|
+
value << @line.slice!(0)
|
428
|
+
end
|
429
|
+
|
430
|
+
syntax_error!("Expected closing brace }") if count != 0
|
431
|
+
@line.slice!(0)
|
432
|
+
value
|
433
|
+
end
|
434
|
+
|
417
435
|
# Helper for raising exceptions
|
418
436
|
def syntax_error!(message, args = {})
|
419
437
|
args[:orig_line] ||= @orig_line
|
data/lib/slim/template.rb
CHANGED
@@ -9,9 +9,11 @@ module Slim
|
|
9
9
|
RailsTemplate = Temple::Templates::Rails(Slim::Engine,
|
10
10
|
:register_as => :slim,
|
11
11
|
# Use rails-specific generator. This is necessary
|
12
|
-
# to support block capturing
|
13
|
-
# Rails takes care of the capturing by itself.
|
12
|
+
# to support block capturing and streaming.
|
14
13
|
:generator => Temple::Generators::RailsOutputBuffer,
|
15
|
-
|
14
|
+
# Disable the internal slim capturing.
|
15
|
+
# Rails takes care of the capturing by itself.
|
16
|
+
:disable_capture => true,
|
17
|
+
:streaming => true)
|
16
18
|
end
|
17
19
|
end
|
data/lib/slim/version.rb
CHANGED
data/slim.gemspec
CHANGED
@@ -19,16 +19,19 @@ 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.
|
23
|
-
s.add_runtime_dependency('tilt', ['~> 1.2'])
|
22
|
+
s.add_runtime_dependency('temple', ['~> 0.3.3'])
|
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('haml', ['>= 3.1.0'])
|
27
27
|
s.add_development_dependency('sass', ['>= 3.1.0'])
|
28
28
|
s.add_development_dependency('minitest', ['>= 0'])
|
29
|
-
s.add_development_dependency('rcov', ['>= 0'])
|
30
29
|
s.add_development_dependency('rdiscount', ['>= 0'])
|
31
30
|
s.add_development_dependency('liquid', ['>= 0'])
|
32
31
|
s.add_development_dependency('yard', ['>= 0'])
|
33
32
|
s.add_development_dependency('creole', ['>= 0'])
|
33
|
+
|
34
|
+
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
35
|
+
s.add_development_dependency('rcov', ['>= 0'])
|
36
|
+
end
|
34
37
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{integration/rails/dummy → rails}/db/migrate/20101220223037_parents_and_children.rb
RENAMED
File without changes
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
|
4
|
-
require File.expand_path("
|
4
|
+
require File.expand_path("../../config/environment.rb", __FILE__)
|
5
5
|
require "rails/test_help"
|
6
6
|
|
7
7
|
Rails.backtrace_cleaner.remove_silencers!
|
8
8
|
|
9
9
|
# Run any available migration
|
10
|
-
ActiveRecord::Migrator.migrate File.expand_path("
|
10
|
+
ActiveRecord::Migrator.migrate File.expand_path("../../db/migrate/", __FILE__)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
3
|
class TestSlimRails < ActionController::IntegrationTest
|
4
4
|
test "normal view" do
|
@@ -54,7 +54,7 @@ class TestSlimRails < ActionController::IntegrationTest
|
|
54
54
|
'<h2>Children</h2>'+
|
55
55
|
'<ul><li><input id="parent_children_attributes_0_name" name="parent[children_attributes][0][name]" size="30" type="text" value="c1" /></li>'+
|
56
56
|
'<input id="parent_children_attributes_0_id" name="parent[children_attributes][0][id]" type="hidden" value="1" /></ul>'+
|
57
|
-
'
|
57
|
+
'</form>'
|
58
58
|
end
|
59
59
|
|
60
60
|
protected
|
@@ -62,13 +62,13 @@ end
|
|
62
62
|
class Env
|
63
63
|
attr_reader :var
|
64
64
|
|
65
|
-
class HtmlSafeString < String
|
65
|
+
class ::HtmlSafeString < String
|
66
66
|
def html_safe?
|
67
67
|
true
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
class HtmlUnsafeString < String
|
71
|
+
class ::HtmlUnsafeString < String
|
72
72
|
def html_safe?
|
73
73
|
false
|
74
74
|
end
|
@@ -71,6 +71,15 @@ h1#title This is my title
|
|
71
71
|
assert_html '<h1 id="title">This is my title</h1><div class="hello world" id="notice">Hello World from @env</div>', source
|
72
72
|
end
|
73
73
|
|
74
|
+
def test_render_with_overwritten_default_tag
|
75
|
+
source = %q{
|
76
|
+
#notice.hello.world
|
77
|
+
= hello_world
|
78
|
+
}
|
79
|
+
|
80
|
+
assert_html '<section class="hello world" id="notice">Hello World from @env</section>', source, :default_tag => 'section'
|
81
|
+
end
|
82
|
+
|
74
83
|
def test_render_with_text_block
|
75
84
|
source = %q{
|
76
85
|
p
|
@@ -19,7 +19,17 @@ p = hello_world + \
|
|
19
19
|
unknown_ruby_method
|
20
20
|
}
|
21
21
|
|
22
|
-
|
22
|
+
# FIXME: Remove this hack!
|
23
|
+
# This is actually a jruby issue. Jruby reports a wrong
|
24
|
+
# line number 1 in this case:
|
25
|
+
#
|
26
|
+
# test = 1+\
|
27
|
+
# unknown_variable
|
28
|
+
if RUBY_PLATFORM == "java"
|
29
|
+
assert_ruby_error NameError, "test.slim:2", source, :file => 'test.slim'
|
30
|
+
else
|
31
|
+
assert_ruby_error NameError, "test.slim:4", source, :file => 'test.slim'
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
def test_broken_output_line2
|
@@ -9,6 +9,14 @@ p id="a#{id_helper}b" = hello_world
|
|
9
9
|
assert_html '<p id="anoticeb">Hello World from @env</p>', source
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_nested_interpolation_in_attribute
|
13
|
+
source = %q{
|
14
|
+
p id="#{"abc#{1+1}" + "("}" = hello_world
|
15
|
+
}
|
16
|
+
|
17
|
+
assert_html '<p id="abc2(">Hello World from @env</p>', source
|
18
|
+
end
|
19
|
+
|
12
20
|
def test_interpolation_in_text
|
13
21
|
source = %q{
|
14
22
|
p
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,34 +11,34 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-08-
|
14
|
+
date: 2011-08-26 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: &2161719440 !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.3
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *2161719440
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: tilt
|
30
|
-
requirement: &
|
30
|
+
requirement: &2161718920 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 1.3.2
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *2161718920
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
41
|
-
requirement: &
|
41
|
+
requirement: &2161718440 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: 0.8.7
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *2161718440
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: haml
|
52
|
-
requirement: &
|
52
|
+
requirement: &2161717960 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: 3.1.0
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *2161717960
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: sass
|
63
|
-
requirement: &
|
63
|
+
requirement: &2152313300 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ! '>='
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 3.1.0
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *2152313300
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: minitest
|
74
|
-
requirement: &
|
74
|
+
requirement: &2152312820 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '0'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *2152312820
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
-
requirement: &
|
84
|
+
name: rdiscount
|
85
|
+
requirement: &2152312340 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ! '>='
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *2152312340
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
96
|
-
requirement: &
|
95
|
+
name: liquid
|
96
|
+
requirement: &2152311860 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *2152311860
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
107
|
-
requirement: &
|
106
|
+
name: yard
|
107
|
+
requirement: &2152311380 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
110
|
- - ! '>='
|
@@ -112,10 +112,10 @@ dependencies:
|
|
112
112
|
version: '0'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
|
-
version_requirements: *
|
115
|
+
version_requirements: *2152311380
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
|
-
name:
|
118
|
-
requirement: &
|
117
|
+
name: creole
|
118
|
+
requirement: &2152310900 !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
121
121
|
- - ! '>='
|
@@ -123,10 +123,10 @@ dependencies:
|
|
123
123
|
version: '0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
|
-
version_requirements: *
|
126
|
+
version_requirements: *2152310900
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
129
|
-
requirement: &
|
128
|
+
name: rcov
|
129
|
+
requirement: &2152310380 !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
132
132
|
- - ! '>='
|
@@ -134,7 +134,7 @@ dependencies:
|
|
134
134
|
version: '0'
|
135
135
|
type: :development
|
136
136
|
prerelease: false
|
137
|
-
version_requirements: *
|
137
|
+
version_requirements: *2152310380
|
138
138
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
139
139
|
parts without becoming cryptic.
|
140
140
|
email:
|
@@ -149,17 +149,18 @@ extra_rdoc_files:
|
|
149
149
|
files:
|
150
150
|
- .gemtest
|
151
151
|
- .gitignore
|
152
|
+
- .travis.yml
|
152
153
|
- .yardopts
|
153
154
|
- CHANGES
|
154
155
|
- Gemfile
|
155
156
|
- LICENSE
|
156
157
|
- README.md
|
157
158
|
- Rakefile
|
159
|
+
- benchmarks/complex.erb
|
160
|
+
- benchmarks/complex.haml
|
161
|
+
- benchmarks/complex.slim
|
162
|
+
- benchmarks/complex_view.rb
|
158
163
|
- benchmarks/run.rb
|
159
|
-
- benchmarks/src/complex.erb
|
160
|
-
- benchmarks/src/complex.haml
|
161
|
-
- benchmarks/src/complex.slim
|
162
|
-
- benchmarks/src/complex_view.rb
|
163
164
|
- bin/slimrb
|
164
165
|
- extra/slim-mode.el
|
165
166
|
- extra/test.slim
|
@@ -178,47 +179,47 @@ files:
|
|
178
179
|
- lib/slim/version.rb
|
179
180
|
- lib/slim/wrapper.rb
|
180
181
|
- slim.gemspec
|
181
|
-
- test/
|
182
|
-
- test/
|
183
|
-
- test/
|
184
|
-
- test/
|
185
|
-
- test/
|
186
|
-
- test/
|
187
|
-
- test/
|
188
|
-
- test/
|
189
|
-
- test/
|
190
|
-
- test/
|
191
|
-
- test/
|
192
|
-
- test/
|
193
|
-
- test/
|
194
|
-
- test/
|
195
|
-
- test/
|
196
|
-
- test/
|
197
|
-
- test/
|
198
|
-
- test/
|
199
|
-
- test/
|
200
|
-
- test/
|
201
|
-
- test/
|
202
|
-
- test/
|
203
|
-
- test/
|
204
|
-
- test/
|
205
|
-
- test/
|
206
|
-
- test/
|
207
|
-
- test/
|
208
|
-
- test/
|
209
|
-
- test/
|
210
|
-
- test/
|
211
|
-
- test/
|
212
|
-
- test/
|
213
|
-
- test/
|
214
|
-
- test/
|
215
|
-
- test/
|
216
|
-
- test/
|
217
|
-
- test/
|
218
|
-
- test/
|
219
|
-
- test/
|
220
|
-
- test/
|
221
|
-
- test/
|
182
|
+
- test/rails/Rakefile
|
183
|
+
- test/rails/app/controllers/application_controller.rb
|
184
|
+
- test/rails/app/controllers/parents_controller.rb
|
185
|
+
- test/rails/app/controllers/slim_controller.rb
|
186
|
+
- test/rails/app/helpers/application_helper.rb
|
187
|
+
- test/rails/app/models/child.rb
|
188
|
+
- test/rails/app/models/parent.rb
|
189
|
+
- test/rails/app/views/layouts/application.html.slim
|
190
|
+
- test/rails/app/views/parents/_form.html.slim
|
191
|
+
- test/rails/app/views/parents/edit.html.slim
|
192
|
+
- test/rails/app/views/parents/new.html.slim
|
193
|
+
- test/rails/app/views/parents/show.html.slim
|
194
|
+
- test/rails/app/views/slim/_partial.html.slim
|
195
|
+
- test/rails/app/views/slim/content_for.html.slim
|
196
|
+
- test/rails/app/views/slim/erb.html.erb
|
197
|
+
- test/rails/app/views/slim/integers.html.slim
|
198
|
+
- test/rails/app/views/slim/nil.html.slim
|
199
|
+
- test/rails/app/views/slim/no_layout.html.slim
|
200
|
+
- test/rails/app/views/slim/normal.html.slim
|
201
|
+
- test/rails/app/views/slim/partial.html.slim
|
202
|
+
- test/rails/app/views/slim/variables.html.slim
|
203
|
+
- test/rails/config.ru
|
204
|
+
- test/rails/config/application.rb
|
205
|
+
- test/rails/config/boot.rb
|
206
|
+
- test/rails/config/database.yml
|
207
|
+
- test/rails/config/environment.rb
|
208
|
+
- test/rails/config/environments/development.rb
|
209
|
+
- test/rails/config/environments/production.rb
|
210
|
+
- test/rails/config/environments/test.rb
|
211
|
+
- test/rails/config/initializers/backtrace_silencers.rb
|
212
|
+
- test/rails/config/initializers/inflections.rb
|
213
|
+
- test/rails/config/initializers/mime_types.rb
|
214
|
+
- test/rails/config/initializers/secret_token.rb
|
215
|
+
- test/rails/config/initializers/session_store.rb
|
216
|
+
- test/rails/config/locales/en.yml
|
217
|
+
- test/rails/config/routes.rb
|
218
|
+
- test/rails/db/migrate/20101220223037_parents_and_children.rb
|
219
|
+
- test/rails/script/rails
|
220
|
+
- test/rails/test/helper.rb
|
221
|
+
- test/rails/test/test_slim_rails.rb
|
222
|
+
- test/slim/helper.rb
|
222
223
|
- test/slim/test_chain_manipulation.rb
|
223
224
|
- test/slim/test_code_blocks.rb
|
224
225
|
- test/slim/test_code_escaping.rb
|