slim 3.0.9 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +21 -44
- data/CHANGES +18 -0
- data/Gemfile +27 -30
- data/README.jp.md +27 -11
- data/README.md +27 -10
- data/Rakefile +15 -28
- data/benchmarks/view.erb +4 -2
- data/benchmarks/view.haml +3 -1
- data/benchmarks/view.slim +3 -1
- data/lib/slim/command.rb +13 -13
- data/lib/slim/embedded.rb +20 -45
- data/lib/slim/filter.rb +2 -2
- data/lib/slim/grammar.rb +8 -5
- data/lib/slim/parser.rb +17 -10
- data/lib/slim/splat/builder.rb +1 -1
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -1
- data/test/core/test_code_blocks.rb +11 -0
- data/test/core/test_code_output.rb +4 -4
- data/test/core/test_commands.rb +4 -4
- data/test/core/test_embedded_engines.rb +79 -78
- data/test/core/test_html_attributes.rb +1 -1
- data/test/core/test_ruby_errors.rb +2 -28
- data/test/literate/TESTS.md +18 -35
- data/test/rails/app/assets/config/manifest.js +1 -0
- data/test/rails/config/application.rb +17 -0
- data/test/rails/test/helper.rb +3 -0
- data/test/rails/test/test_slim.rb +2 -2
- data/test/sinatra/contest.rb +91 -0
- data/test/sinatra/helper.rb +145 -0
- data/test/sinatra/test_core.rb +91 -0
- data/test/sinatra/test_include.rb +16 -0
- data/test/sinatra/views/embed_include_js.slim +8 -0
- data/test/sinatra/views/embed_js.slim +11 -0
- data/test/sinatra/views/footer.slim +1 -0
- data/test/sinatra/views/hello.slim +1 -0
- data/test/sinatra/views/layout2.slim +3 -0
- metadata +15 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 374bad17fd98e439f41336ea3a634afd4e918708803ada3d211071e565d3ba34
|
4
|
+
data.tar.gz: 94a7178a4263ec906413f4f5ce921fa2ddb12423fcd6e28bbb8fbd456bc2ebb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 282bb0085cd7e91ddffbc4fc9af6ab82ec4478ef2090a82592bf96a395f2ad172c6af9f1010f5e0e9cee57281c487e5e2bb4b25a75e2eac0df02018bc298faf9
|
7
|
+
data.tar.gz: 7924d7af215643a8207b738f3f97c46f32bb990db7a103987f14b8b9558ec7de9208aaf27c65840d7caa7d60c156e56f6f876dd7ff54190da91fc436ccc75842
|
data/.travis.yml
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
+
# https://www.ruby-lang.org/en/downloads/releases/
|
1
2
|
language: ruby
|
2
|
-
|
3
3
|
rvm:
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
-
|
9
|
-
- rbx-3
|
10
|
-
- jruby-head
|
11
|
-
- jruby-19mode
|
4
|
+
- 2.6.1
|
5
|
+
- 2.5.3
|
6
|
+
- 2.4.5
|
7
|
+
- jruby-9.2.6.0
|
8
|
+
- jruby-9.1.17.0
|
12
9
|
|
13
|
-
sudo
|
10
|
+
# Recommend sudo required when using trusty dist
|
11
|
+
# https://docs.travis-ci.com/user/reference/trusty/
|
12
|
+
sudo: required
|
14
13
|
dist: trusty
|
15
14
|
|
16
15
|
script: "bundle exec rake $TASK"
|
@@ -20,42 +19,20 @@ after_success:
|
|
20
19
|
|
21
20
|
env:
|
22
21
|
global:
|
23
|
-
# travis encrypt CODECLIMATE_REPO_TOKEN=???
|
24
22
|
- secure: "a7sD9iwPJJn3Fj+mn62GAmy/PEguh3elrilsp1KS+WfDiCiIKD8Q5KG2Jv67DGcQAGI3dPWeh7+ZhZ/W7nEipwWUBmSvGYVeoF63y8j6mNRLeekqspj94l47hXyFePj9bCadY1b1/xY4lE1pMEU8eA8AOUHUqCSuH+Kk/MuvyLM="
|
25
23
|
matrix:
|
26
|
-
- "TASK=test:core_and_plugins
|
27
|
-
- "TASK=test:
|
28
|
-
- "TASK=test:
|
29
|
-
- "TASK=test:
|
30
|
-
- "TASK=test:rails RAILS=
|
31
|
-
- "TASK=test:
|
32
|
-
- "TASK=test:
|
33
|
-
- "TASK=test:
|
34
|
-
- "TASK=test:rails RAILS=4.1.10"
|
35
|
-
- "TASK=test:rails RAILS=4.2.1"
|
36
|
-
- "TASK=test:sinatra SINATRA=master"
|
37
|
-
- "TASK=test:sinatra SINATRA=1.3.6"
|
38
|
-
- "TASK=test:sinatra SINATRA=1.4.6"
|
39
|
-
- "TASK=bench"
|
40
|
-
- "TASK=bench slow=1"
|
24
|
+
- "TASK=test:core_and_plugins"
|
25
|
+
- "TASK=test:rails RAILS=6.0.0.beta2"
|
26
|
+
- "TASK=test:rails RAILS=5.2.2"
|
27
|
+
- "TASK=test:rails RAILS=5.2.1.1"
|
28
|
+
- "TASK=test:rails RAILS=5.2.1"
|
29
|
+
- "TASK=test:sinatra SINATRA=2.0.5"
|
30
|
+
- "TASK=test:sinatra SINATRA=2.0.4"
|
31
|
+
- "TASK=test:sinatra SINATRA=2.0.3"
|
41
32
|
|
42
33
|
matrix:
|
43
34
|
exclude:
|
44
|
-
- rvm:
|
45
|
-
env: "TASK=test:rails RAILS=
|
46
|
-
- rvm:
|
47
|
-
env: "TASK=test:rails RAILS=
|
48
|
-
- rvm: 2.3.3
|
49
|
-
env: "TASK=test:rails RAILS=3.1.12 TILT=1.3.4"
|
50
|
-
- rvm: 2.3.3
|
51
|
-
env: "TASK=test:rails RAILS=3.2.21 TILT=1.3.4"
|
52
|
-
allow_failures:
|
53
|
-
- env: "TASK=test:core_and_plugins TILT=master"
|
54
|
-
- env: "TASK=test:rails RAILS=master"
|
55
|
-
- env: "TASK=test:sinatra SINATRA=master"
|
56
|
-
- rvm: ruby-head
|
57
|
-
- rvm: jruby-19mode
|
58
|
-
- rvm: jruby-head
|
59
|
-
|
60
|
-
notifications:
|
61
|
-
irc: "chat.freenode.net#slim-lang"
|
35
|
+
- rvm: 2.4.5
|
36
|
+
env: "TASK=test:rails RAILS=6.0.0.beta2"
|
37
|
+
- rvm: jruby-9.1.17.0
|
38
|
+
env: "TASK=test:rails RAILS=6.0.0.beta2"
|
data/CHANGES
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
4.1.0 (2020-05-07)
|
2
|
+
* Add support for Tailwind CSS - #841
|
3
|
+
* Update dependencies and testing
|
4
|
+
|
5
|
+
4.0.1 (2018-09-02)
|
6
|
+
|
7
|
+
* Fix incompatibility issue with Slim Include plugin and new ability to specifiy attributes for embedded engines #819
|
8
|
+
|
9
|
+
4.0.0 (2018-08-26)
|
10
|
+
|
11
|
+
* Add ability to specify attributes for embedded engines using TagEngine - #653
|
12
|
+
* Set Tilt's default encoding to utf-8 - #800
|
13
|
+
* Prevent generation of invalid Ruby code in heredoc - #770
|
14
|
+
* Don't convert underscores to dashes on data attributes - #807 [Backward incompatible]
|
15
|
+
* Update description in README.jp.md - #795
|
16
|
+
* Removed support for embedded engines: Asciidoc, Builder, Creole, Erb, Nokogiri, Opal, Org-Ruby, Styl, Wikicloth
|
17
|
+
* Fix tests
|
18
|
+
|
1
19
|
3.0.9 (2017-11-09)
|
2
20
|
|
3
21
|
* Fixed Cross-site Scripting in splat attributes names (See #767)
|
data/Gemfile
CHANGED
@@ -2,13 +2,28 @@ source 'https://rubygems.org/'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
gem '
|
5
|
+
group :test do
|
6
|
+
gem 'sinatra'
|
7
|
+
gem 'rack-test'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :perf do
|
11
|
+
gem 'benchmark-ips'
|
12
|
+
gem 'erubis'
|
13
|
+
gem 'haml'
|
14
|
+
end
|
15
|
+
|
16
|
+
if ENV['TRAVIS']
|
17
|
+
gem 'rails-controller-testing'
|
18
|
+
end
|
19
|
+
|
20
|
+
if ENV['TEMPLE'] == 'master'
|
21
|
+
gem 'temple', :github => 'judofyr/temple'
|
7
22
|
end
|
8
23
|
|
9
24
|
if ENV['TILT']
|
10
25
|
if ENV['TILT'] == 'master'
|
11
|
-
gem 'tilt', github
|
26
|
+
gem 'tilt', :github => 'rtomayko/tilt'
|
12
27
|
else
|
13
28
|
gem 'tilt', "= #{ENV['TILT']}"
|
14
29
|
end
|
@@ -16,51 +31,33 @@ end
|
|
16
31
|
|
17
32
|
if ENV['RAILS']
|
18
33
|
# we need some smarter test logic for the different Rails versions
|
19
|
-
if RUBY_VERSION >= '2.1.0'
|
20
|
-
gem 'nokogiri'
|
21
|
-
else
|
22
|
-
gem 'nokogiri', '~> 1.6.8'
|
23
|
-
end
|
24
|
-
|
25
34
|
if ENV['RAILS'] == 'master'
|
26
|
-
gem 'rails', github
|
35
|
+
gem 'rails', :github => 'rails/rails'
|
27
36
|
else
|
28
37
|
gem 'rails', "= #{ENV['RAILS']}"
|
29
38
|
end
|
30
|
-
end
|
31
39
|
|
32
|
-
|
33
|
-
if (ENV['SINATRA'] && ENV['SINATRA'] < '1.4.6') || (ENV['RAILS'] && ENV['RAILS'].match(/^(3|4\.0)/))
|
34
|
-
gem 'minitest', '~> 4.7.4'
|
35
|
-
else
|
36
|
-
gem 'minitest', '~> 5.1'
|
40
|
+
gem 'slim-rails', require: false
|
37
41
|
end
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
gem 'test-unit', platforms: :mri
|
42
|
-
end
|
43
|
+
gem 'test-unit', '~> 3.3', '>= 3.3.5'
|
44
|
+
gem 'minitest', '~> 5.14'
|
43
45
|
|
44
46
|
if RUBY_ENGINE == 'rbx' && !ENV['TRAVIS']
|
45
47
|
gem 'psych'
|
46
48
|
end
|
47
49
|
|
48
50
|
if ENV['SINATRA']
|
49
|
-
gem 'rack-test'
|
50
51
|
if ENV['SINATRA'] == 'master'
|
51
|
-
gem 'sinatra', github
|
52
|
+
gem 'sinatra', :github => 'sinatra/sinatra'
|
52
53
|
else
|
53
|
-
gem 'sinatra', "
|
54
|
+
gem 'sinatra', :tag => "v#{ENV['SINATRA']}"
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
gem 'rake', '>= 0.
|
58
|
-
gem '
|
59
|
-
gem 'kramdown'
|
60
|
-
gem 'creole'
|
61
|
-
gem 'builder'
|
62
|
-
gem 'asciidoctor'
|
63
|
-
gem 'org-ruby'
|
58
|
+
gem 'rake', '~> 13.0', '>= 13.0.1'
|
59
|
+
gem 'sassc', '~> 2.2', '>= 2.2.1'
|
60
|
+
gem 'kramdown', '~> 2.1'
|
64
61
|
|
65
62
|
if ENV['TASK'] == 'bench'
|
66
63
|
gem 'benchmark-ips'
|
data/README.jp.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
-
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim) [![Build Status](https://img.shields.io/travis/slim-template/slim.svg?branch=master)](http://travis-ci.org/slim-template/slim) [![
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim) [![Build Status](https://img.shields.io/travis/slim-template/slim.svg?branch=master)](http://travis-ci.org/slim-template/slim) [![Code Climate](https://codeclimate.com/github/slim-template/slim/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim) [![Test Coverage](https://codeclimate.com/github/slim-template/slim/badges/coverage.svg)](https://codeclimate.com/github/slim-template/slim/coverage)
|
4
4
|
[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](https://flattr.com/submit/auto?user_id=min4d&url=http%3A%2F%2Fslim-lang.org%2F "Donate monthly to this project using Flattr")
|
5
5
|
|
6
6
|
Slim は 不可解にならない程度に view の構文を本質的な部品まで減らすことを目指したテンプレート言語です。標準的な HTML テンプレートからどれだけのものを減らせるか、検証するところから始まりました。(<, >, 閉じタグなど) 多くの人が Slim に興味を持ったことで, 機能的で柔軟な構文に成長しました。
|
@@ -40,7 +40,7 @@ Slim は 不可解にならない程度に view の構文を本質的な部品
|
|
40
40
|
|
41
41
|
### Slim とは?
|
42
42
|
|
43
|
-
Slim は __Rails3
|
43
|
+
Slim は __Rails3 以降__ に対応した高速, 軽量なテンプレートエンジンです。主要な Ruby の実装全てでしっかりテストされています。
|
44
44
|
私たちは継続的インテグレーションを採用しています。(travis-ci)
|
45
45
|
|
46
46
|
Slim の核となる構文は1つの考えによって導かれています: "この動作を行うために最低限必要なものは何か。"
|
@@ -118,8 +118,7 @@ html
|
|
118
118
|
|
119
119
|
### テキスト `|`
|
120
120
|
|
121
|
-
パイプを使うと, Slim
|
122
|
-
パイプよりも深くインデントされた全ての行がコピーされます。
|
121
|
+
パイプを使うと, Slim はパイプよりも深くインデントされた全ての行をコピーします。行中の処理は基本的にどのようなものでもエスケープされます。
|
123
122
|
|
124
123
|
~~~ slim
|
125
124
|
body
|
@@ -869,17 +868,10 @@ p: markdown: Tag with **inline** markdown!
|
|
869
868
|
| sass: | sass | コンパイル時 | sass コードを埋め込み、style タグで囲む |
|
870
869
|
| scss: | sass | コンパイル時 | scss コードを埋め込み、style タグで囲む |
|
871
870
|
| less: | less | コンパイル時 | less コードを埋め込み、style タグで囲む |
|
872
|
-
| styl: | styl | コンパイル時 | stylus コードを埋め込み、 style タグで囲む |
|
873
871
|
| coffee: | coffee-script | コンパイル時 | CoffeeScript をコンパイルし、 script タグで囲む |
|
874
|
-
| asciidoc: | asciidoctor | コンパイル時 + 展開 | AsciiDoc をコンパイルし、テキスト中の # \{variables} を展開 |
|
875
872
|
| markdown: | redcarpet/rdiscount/kramdown | コンパイル時 + 展開 | Markdown をコンパイルし、テキスト中の # \{variables} を展開 |
|
876
873
|
| textile: | redcloth | コンパイル時 + 展開 | textile をコンパイルし、テキスト中の # \{variables} を展開 |
|
877
|
-
| creole: | creole | コンパイル時 + 展開 | cleole をコンパイルし、テキスト中の # \{variables} を展開 |
|
878
|
-
| wiki:, mediawiki: | wikicloth | コンパイル時 + 展開 | wiki をコンパイルし、テキスト中の # \{variables} を展開 |
|
879
874
|
| rdoc: | rdoc | コンパイル時 + 展開 | RDoc をコンパイルし、テキスト中の # \{variables} を展開 |
|
880
|
-
| builder: | builder | プレコンパイル | builder コードの埋め込み |
|
881
|
-
| nokogiri: | nokogiri | プレコンパイル | nokogiri コードの埋め込み |
|
882
|
-
| erb: | なし | プレコンパイル | erb コードの埋め込み |
|
883
875
|
|
884
876
|
埋め込みエンジンは Slim の `Slim::Embedded` フィルタのオプションで直接設定されます。例:
|
885
877
|
|
@@ -887,6 +879,29 @@ p: markdown: Tag with **inline** markdown!
|
|
887
879
|
Slim::Embedded.options[:markdown] = {auto_ids: false}
|
888
880
|
~~~
|
889
881
|
|
882
|
+
以下埋め込みエンジンの場合はHTMLのattributeも指定できます:
|
883
|
+
|
884
|
+
* Javascript
|
885
|
+
* CSS
|
886
|
+
* CoffeeScript
|
887
|
+
* LESS
|
888
|
+
* SASS
|
889
|
+
* SCSS
|
890
|
+
|
891
|
+
例:
|
892
|
+
|
893
|
+
~~~ scss
|
894
|
+
scss class="myClass":
|
895
|
+
$color: #f00;
|
896
|
+
body { color: $color; }
|
897
|
+
~~~
|
898
|
+
|
899
|
+
レンダリング結果:
|
900
|
+
|
901
|
+
~~~ html
|
902
|
+
<style class="myClass" type="text/css">body{color:red}</style>
|
903
|
+
~~~
|
904
|
+
|
890
905
|
## Slim の設定
|
891
906
|
|
892
907
|
Slim とその基礎となる [Temple](https://github.com/judofyr/temple) は非常に柔軟に設定可能です。
|
@@ -1271,3 +1286,4 @@ Slim は [MIT license](http://www.opensource.org/licenses/MIT) に基づいて
|
|
1271
1286
|
* [Pug (Successor of Jade, Similar engine for javascript)](https://github.com/pugjs/pug)
|
1272
1287
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
1273
1288
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
1289
|
+
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
-
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim) [![Build Status](https://img.shields.io/travis/slim-template/slim.svg?branch=master)](http://travis-ci.org/slim-template/slim) [![
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim) [![Build Status](https://img.shields.io/travis/slim-template/slim.svg?branch=master)](http://travis-ci.org/slim-template/slim) [![Code Climate](https://codeclimate.com/github/slim-template/slim/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim) [![Test Coverage](https://codeclimate.com/github/slim-template/slim/badges/coverage.svg)](https://codeclimate.com/github/slim-template/slim/coverage)
|
4
4
|
[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](https://flattr.com/submit/auto?user_id=min4d&url=http%3A%2F%2Fslim-lang.org%2F "Donate monthly to this project using Flattr")
|
5
5
|
|
6
6
|
Slim is a template language whose goal is to reduce the view syntax to the essential parts without becoming cryptic. It started as an exercise to see how much could be removed from a standard html template (<, >, closing tags, etc...). As more people took an interest in Slim, the functionality grew and so did the flexibility of the syntax.
|
@@ -40,7 +40,7 @@ A short list of the features...
|
|
40
40
|
|
41
41
|
### What is Slim?
|
42
42
|
|
43
|
-
Slim is a fast, lightweight templating engine with support for __Rails 3 and
|
43
|
+
Slim is a fast, lightweight templating engine with support for __Rails 3 and later__. It has been heavily tested on all major ruby implementations. We use
|
44
44
|
continuous integration (travis-ci).
|
45
45
|
|
46
46
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
@@ -869,17 +869,10 @@ Supported engines:
|
|
869
869
|
| sass: | sass | Compile time | Embed sass code and wrap in style tag |
|
870
870
|
| scss: | sass | Compile time | Embed scss code and wrap in style tag |
|
871
871
|
| less: | less | Compile time | Embed less css code and wrap in style tag |
|
872
|
-
| styl: | styl | Compile time | Embed stylus css code and wrap in style tag |
|
873
872
|
| coffee: | coffee-script | Compile time | Compile coffee script code and wrap in script tag |
|
874
|
-
| asciidoc: | asciidoctor | Compile time + Interpolation | Compile AsciiDoc code and interpolate #\{variables} in text |
|
875
873
|
| markdown: | redcarpet/rdiscount/kramdown | Compile time + Interpolation | Compile markdown code and interpolate #\{variables} in text |
|
876
874
|
| textile: | redcloth | Compile time + Interpolation | Compile textile code and interpolate #\{variables} in text |
|
877
|
-
| creole: | creole | Compile time + Interpolation | Compile creole code and interpolate #\{variables} in text |
|
878
|
-
| wiki:, mediawiki: | wikicloth | Compile time + Interpolation | Compile wiki code and interpolate #\{variables} in text |
|
879
875
|
| rdoc: | rdoc | Compile time + Interpolation | Compile rdoc code and interpolate #\{variables} in text |
|
880
|
-
| builder: | builder | Precompiled | Embed builder code |
|
881
|
-
| nokogiri: | nokogiri | Precompiled | Embed nokogiri builder code |
|
882
|
-
| erb: | none | Precompiled | Embed erb code |
|
883
876
|
|
884
877
|
The embedded engines can be configured in Slim by setting the options directly on the `Slim::Embedded` filter. Example:
|
885
878
|
|
@@ -887,6 +880,28 @@ The embedded engines can be configured in Slim by setting the options directly o
|
|
887
880
|
Slim::Embedded.options[:markdown] = {auto_ids: false}
|
888
881
|
~~~
|
889
882
|
|
883
|
+
You can also specify HTML attributes for the following embedded engines:
|
884
|
+
* Javascript
|
885
|
+
* CSS
|
886
|
+
* CoffeeScript
|
887
|
+
* LESS
|
888
|
+
* SASS
|
889
|
+
* SCSS
|
890
|
+
|
891
|
+
Example:
|
892
|
+
|
893
|
+
~~~ scss
|
894
|
+
scss class="myClass":
|
895
|
+
$color: #f00;
|
896
|
+
body { color: $color; }
|
897
|
+
~~~
|
898
|
+
|
899
|
+
This will generate the following HTML:
|
900
|
+
|
901
|
+
~~~ html
|
902
|
+
<style class="myClass" type="text/css">body{color:red}</style>
|
903
|
+
~~~
|
904
|
+
|
890
905
|
## Configuring Slim
|
891
906
|
|
892
907
|
Slim and the underlying [Temple](https://github.com/judofyr/temple) framework are highly configurable.
|
@@ -1105,7 +1120,7 @@ Usage: slimrb [options]
|
|
1105
1120
|
-e, --erb Convert to ERB
|
1106
1121
|
--rails Generate rails compatible code (Implies --compile)
|
1107
1122
|
-r, --require library Load library or plugin with -r slim/plugin
|
1108
|
-
-p, --pretty Produce pretty html
|
1123
|
+
-p, --pretty Produce pretty html for debugging purposes
|
1109
1124
|
-o, --option name=code Set slim option
|
1110
1125
|
-l, --locals Hash|YAML|JSON Set local variables
|
1111
1126
|
-h, --help Show this message
|
@@ -1251,6 +1266,7 @@ Static code analysis:
|
|
1251
1266
|
|
1252
1267
|
Template Converters (HAML, ERB, ...):
|
1253
1268
|
|
1269
|
+
* [ERB 2 Slim](http://erb2slim.com/)
|
1254
1270
|
* [Haml2Slim converter](https://github.com/slim-template/haml2slim)
|
1255
1271
|
* [ERB2Slim, HTML2Slim converter](https://github.com/slim-template/html2slim)
|
1256
1272
|
|
@@ -1271,3 +1287,4 @@ Language ports/Similar languages:
|
|
1271
1287
|
* [Pug (Successor of Jade, Similar engine for javascript)](https://github.com/pugjs/pug)
|
1272
1288
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
1273
1289
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
1290
|
+
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/Rakefile
CHANGED
@@ -19,67 +19,54 @@ namespace 'test' do
|
|
19
19
|
Rake::TestTask.new('core') do |t|
|
20
20
|
t.libs << 'lib' << 'test/core'
|
21
21
|
t.test_files = FileList['test/core/test_*.rb']
|
22
|
-
t.
|
22
|
+
t.warning = true
|
23
23
|
#t.ruby_opts << '-w' << '-v'
|
24
24
|
end
|
25
25
|
|
26
26
|
Rake::TestTask.new('literate') do |t|
|
27
27
|
t.libs << 'lib' << 'test/literate'
|
28
28
|
t.test_files = FileList['test/literate/run.rb']
|
29
|
-
t.
|
29
|
+
t.warning = true
|
30
30
|
end
|
31
31
|
|
32
32
|
Rake::TestTask.new('logic_less') do |t|
|
33
33
|
t.libs << 'lib' << 'test/core'
|
34
34
|
t.test_files = FileList['test/logic_less/test_*.rb']
|
35
|
-
t.
|
35
|
+
t.warning = true
|
36
36
|
end
|
37
37
|
|
38
38
|
Rake::TestTask.new('translator') do |t|
|
39
39
|
t.libs << 'lib' << 'test/core'
|
40
40
|
t.test_files = FileList['test/translator/test_*.rb']
|
41
|
-
t.
|
41
|
+
t.warning = true
|
42
42
|
end
|
43
43
|
|
44
44
|
Rake::TestTask.new('smart') do |t|
|
45
45
|
t.libs << 'lib' << 'test/core'
|
46
46
|
t.test_files = FileList['test/smart/test_*.rb']
|
47
|
-
t.
|
47
|
+
t.warning = true
|
48
48
|
end
|
49
49
|
|
50
50
|
Rake::TestTask.new('include') do |t|
|
51
51
|
t.libs << 'lib' << 'test/core'
|
52
52
|
t.test_files = FileList['test/include/test_*.rb']
|
53
|
-
t.
|
53
|
+
t.warning = true
|
54
54
|
end
|
55
55
|
|
56
56
|
Rake::TestTask.new('rails') do |t|
|
57
57
|
t.libs << 'lib'
|
58
58
|
t.test_files = FileList['test/rails/test/test_*.rb']
|
59
|
-
t.
|
59
|
+
t.warning = true
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
code = File.read(file)
|
71
|
-
code.gsub!('attr_wrapper', 'attr_quote')
|
72
|
-
File.open(file, 'w') {|out| out.write(code) }
|
73
|
-
end
|
74
|
-
|
75
|
-
# Run Slim integration test in Sinatra
|
76
|
-
t.test_files = FileList[file]
|
77
|
-
t.verbose = true
|
78
|
-
end
|
79
|
-
rescue LoadError
|
80
|
-
task :sinatra do
|
81
|
-
abort 'Sinatra is not available'
|
82
|
-
end
|
62
|
+
Rake::TestTask.new('sinatra') do |t|
|
63
|
+
t.libs << 'lib'
|
64
|
+
t.test_files = FileList['test/sinatra/test_*.rb']
|
65
|
+
|
66
|
+
# Copied from test task in Sinatra project to mimic their approach
|
67
|
+
t.ruby_opts = ['-r rubygems'] if defined? Gem
|
68
|
+
t.ruby_opts << '-I.'
|
69
|
+
t.warning = true
|
83
70
|
end
|
84
71
|
end
|
85
72
|
|
data/benchmarks/view.erb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
<!DOCTYPE HTML>
|
2
2
|
|
3
|
-
<html>
|
3
|
+
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<title>Simple Benchmark</title>
|
6
|
+
<meta charset="utf-8">
|
7
|
+
<meta name="description" content="This is an example of a meta description.">
|
6
8
|
</head>
|
7
9
|
<body>
|
8
10
|
<h1><%= header %></h1>
|
@@ -20,4 +22,4 @@
|
|
20
22
|
<p>The list is empty.</p>
|
21
23
|
<% end %>
|
22
24
|
</body>
|
23
|
-
</html>
|
25
|
+
</html>
|
data/benchmarks/view.haml
CHANGED
data/benchmarks/view.slim
CHANGED
data/lib/slim/command.rb
CHANGED
@@ -110,19 +110,19 @@ module Slim
|
|
110
110
|
Template.new(@options[:file]) { @options[:input].read }.render(nil, locals)
|
111
111
|
end
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
113
|
+
rescue Exception => ex
|
114
|
+
raise ex if @options[:trace] || SystemExit === ex
|
115
|
+
$stderr.print "#{ex.class}: " if ex.class != RuntimeError
|
116
|
+
$stderr.puts ex.message
|
117
|
+
$stderr.puts ' Use --trace for backtrace.'
|
118
|
+
exit 1
|
119
|
+
else
|
120
|
+
unless @options[:output]
|
121
|
+
file = args.shift
|
122
|
+
@options[:output] = file ? File.open(file, 'w') : $stdout
|
123
|
+
end
|
124
|
+
@options[:output].puts(result)
|
125
|
+
exit 0
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|