slim 4.1.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +51 -0
- data/.yardopts +1 -1
- data/CHANGES +19 -7
- data/Gemfile +16 -26
- data/LICENSE +1 -1
- data/README.jp.md +19 -20
- data/README.md +23 -24
- data/Rakefile +1 -3
- data/benchmarks/run-benchmarks.rb +7 -12
- data/doc/jp/translator.md +1 -1
- data/doc/logic_less.md +1 -1
- data/doc/translator.md +1 -1
- data/lib/slim/do_inserter.rb +1 -1
- data/lib/slim/embedded.rb +12 -11
- data/lib/slim/end_inserter.rb +2 -2
- data/lib/slim/engine.rb +2 -0
- data/lib/slim/parser.rb +0 -23
- data/lib/slim/railtie.rb +17 -0
- data/lib/slim/splat/builder.rb +8 -2
- data/lib/slim/splat/filter.rb +2 -1
- data/lib/slim/template.rb +0 -14
- data/lib/slim/version.rb +1 -1
- data/lib/slim.rb +1 -0
- data/slim.gemspec +3 -4
- data/test/core/test_code_evaluation.rb +1 -0
- data/test/core/test_code_structure.rb +17 -0
- data/test/core/test_commands.rb +8 -7
- data/test/core/test_embedded_engines.rb +18 -14
- data/test/core/test_erb_converter.rb +4 -6
- data/test/core/test_html_attributes.rb +8 -0
- data/test/core/test_pretty.rb +4 -7
- data/test/literate/TESTS.md +22 -22
- data/test/literate/run.rb +2 -2
- data/test/rails/config/application.rb +0 -17
- data/test/rails/test/test_slim.rb +6 -12
- data/test/sinatra/helper.rb +0 -2
- metadata +11 -17
- data/.travis.yml +0 -38
- data/test/rails/config/initializers/secret_token.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a9cb2acf2b4cdc15e88f19f4b83e7b4ac35ef2bcfe3cce9faff694cd08a761
|
4
|
+
data.tar.gz: 4f097cd7b0c48768b8be27c1d3983826bbdb0dd370b4e617667a6c2b5da7b05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eedadac31b851ef0c1d5552c5f199a36ff11cb4a6b6ac8c80b0c0725e81404327b1edc2d43c01033dcb47d5eefbb7145d989ac3619aa635cd9903d390998d2c
|
7
|
+
data.tar.gz: 71ea954ab4041ee8b02f39e056c4954d0ed814b8eaf9e368a48d5a639a314825717996e263bdab0c414c63143a0fe8de1aed29d3ce68c37ebc6a591e1829750e
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: test
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
6
|
+
pull_request:
|
7
|
+
types:
|
8
|
+
- opened
|
9
|
+
- synchronize
|
10
|
+
- reopened
|
11
|
+
schedule:
|
12
|
+
- cron: "00 15 * * *"
|
13
|
+
jobs:
|
14
|
+
basic:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
26
|
+
- run: bundle install && bundle exec rake test
|
27
|
+
- run: bundle install && bundle exec rake test:sinatra
|
28
|
+
env:
|
29
|
+
SINATRA: 2.2.4
|
30
|
+
- run: bundle install && bundle exec rake test:sinatra
|
31
|
+
env:
|
32
|
+
SINATRA: 3.0.5
|
33
|
+
rails:
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
strategy:
|
36
|
+
fail-fast: false
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v3
|
39
|
+
- name: Set up Ruby
|
40
|
+
uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: 2.7
|
43
|
+
- run: bundle install && bundle exec rake test:rails
|
44
|
+
env:
|
45
|
+
RAILS: 5.2.8
|
46
|
+
- run: bundle install && bundle exec rake test:rails
|
47
|
+
env:
|
48
|
+
RAILS: 6.0.6
|
49
|
+
- run: bundle install && bundle exec rake test:rails
|
50
|
+
env:
|
51
|
+
RAILS: 6.1.7
|
data/.yardopts
CHANGED
data/CHANGES
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
5.0.0 (2023-01-23)
|
2
|
+
|
3
|
+
* Fix markdown interpolation #773
|
4
|
+
* Support case/in #884
|
5
|
+
* Extract slim/railtie #850
|
6
|
+
* css: doesn't add type='text/css' anymore #828
|
7
|
+
* Remove deprecated whitespace syntax =' etc
|
8
|
+
* Add support for annotate_rendered_view_with_filenames #867, #878, #901
|
9
|
+
* Remove deprecated syntax
|
10
|
+
* Add option to hyphenate underscore attributes - #852
|
11
|
+
* Update CI/CD testing and dependencies
|
12
|
+
|
1
13
|
4.1.0 (2020-05-07)
|
2
14
|
* Add support for Tailwind CSS - #841
|
3
15
|
* Update dependencies and testing
|
@@ -120,10 +132,10 @@
|
|
120
132
|
div id=('obj' + name) data={:a => 1, :b => 2} class=['alpha', 'beta']
|
121
133
|
* Quoted attributes are escaped by default
|
122
134
|
Old:
|
123
|
-
a href='http://slim-
|
135
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
124
136
|
New:
|
125
|
-
a href='http://slim-
|
126
|
-
a href=='http://slim-
|
137
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
138
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
127
139
|
You can always disable escaping completly by using :disable_escape if you don't want to write '=='.
|
128
140
|
* Added hyphenation support for data attributes (Option :hyphen_attrs)
|
129
141
|
Example: div data={key1_key2: 2, key1: {key3: 3}} will render as '<div data-key1-key2="2" data-key1-key3="3"></div>'
|
@@ -164,11 +176,11 @@
|
|
164
176
|
* Deprecated :escape_quoted_attrs (done by default in 2.0)
|
165
177
|
* Warn if quoted attributes might be double escaped in Slim 2.0.0
|
166
178
|
Old syntax:
|
167
|
-
a href='http://slim-
|
168
|
-
a href=='http://slim-
|
179
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
180
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
169
181
|
New syntax in 2.0.0:
|
170
|
-
a href='http://slim-
|
171
|
-
a href=='http://slim-
|
182
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
183
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
172
184
|
* Improved pretty printing (Issue #202)
|
173
185
|
* Renamed Slim::EmbeddedEngine to Slim::Embedded (Old constant still available until 2.0)
|
174
186
|
* Renamed Slim::ControlStructures to Slim::Controls
|
data/Gemfile
CHANGED
@@ -2,22 +2,16 @@ source 'https://rubygems.org/'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :test do
|
6
|
-
gem 'sinatra'
|
7
|
-
gem 'rack-test'
|
8
|
-
end
|
9
|
-
|
10
5
|
group :perf do
|
11
6
|
gem 'benchmark-ips'
|
12
|
-
gem '
|
7
|
+
gem 'erubi'
|
13
8
|
gem 'haml'
|
14
9
|
end
|
15
10
|
|
16
|
-
if ENV['
|
17
|
-
gem '
|
18
|
-
|
19
|
-
|
20
|
-
if ENV['TEMPLE'] == 'master'
|
11
|
+
if ENV['TEMPLE'] && ENV['TEMPLE'] != 'master'
|
12
|
+
gem 'temple', "= #{ENV['TEMPLE']}"
|
13
|
+
else
|
14
|
+
# Test against temple master by default
|
21
15
|
gem 'temple', :github => 'judofyr/temple'
|
22
16
|
end
|
23
17
|
|
@@ -30,24 +24,24 @@ if ENV['TILT']
|
|
30
24
|
end
|
31
25
|
|
32
26
|
if ENV['RAILS']
|
27
|
+
gem 'rails-controller-testing'
|
28
|
+
|
33
29
|
# we need some smarter test logic for the different Rails versions
|
34
|
-
if ENV['RAILS'] == '
|
35
|
-
gem 'rails', :github => 'rails/rails'
|
30
|
+
if ENV['RAILS'] == 'main'
|
31
|
+
gem 'rails', :github => 'rails/rails', branch: 'main'
|
36
32
|
else
|
37
33
|
gem 'rails', "= #{ENV['RAILS']}"
|
38
34
|
end
|
39
|
-
|
40
|
-
gem 'slim-rails', require: false
|
41
35
|
end
|
42
36
|
|
43
|
-
gem 'test-unit', '~> 3.
|
44
|
-
gem 'minitest', '~> 5.
|
45
|
-
|
46
|
-
|
47
|
-
gem 'psych'
|
48
|
-
end
|
37
|
+
gem 'test-unit', '~> 3.5'
|
38
|
+
gem 'minitest', '~> 5.15'
|
39
|
+
gem 'rake', '~> 13.0'
|
40
|
+
gem 'kramdown', '~> 2.4'
|
49
41
|
|
50
42
|
if ENV['SINATRA']
|
43
|
+
gem 'rack-test'
|
44
|
+
|
51
45
|
if ENV['SINATRA'] == 'master'
|
52
46
|
gem 'sinatra', :github => 'sinatra/sinatra'
|
53
47
|
else
|
@@ -55,13 +49,9 @@ if ENV['SINATRA']
|
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
58
|
-
gem 'rake', '~> 13.0', '>= 13.0.1'
|
59
|
-
gem 'sassc', '~> 2.2', '>= 2.2.1'
|
60
|
-
gem 'kramdown', '~> 2.1'
|
61
|
-
|
62
52
|
if ENV['TASK'] == 'bench'
|
63
53
|
gem 'benchmark-ips'
|
64
|
-
gem '
|
54
|
+
gem 'erubi'
|
65
55
|
gem 'haml'
|
66
56
|
end
|
67
57
|
|
data/LICENSE
CHANGED
data/README.jp.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
-
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim)
|
4
|
-
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim)
|
4
|
+
![Build Status](https://github.com/slim-template/slim/actions/workflows/test.yml/badge.svg)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/slim-template/slim/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/slim-template/slim/badges/coverage.svg)](https://codeclimate.com/github/slim-template/slim/coverage)
|
7
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
5
8
|
|
6
9
|
Slim は 不可解にならない程度に view の構文を本質的な部品まで減らすことを目指したテンプレート言語です。標準的な HTML テンプレートからどれだけのものを減らせるか、検証するところから始まりました。(<, >, 閉じタグなど) 多くの人が Slim に興味を持ったことで, 機能的で柔軟な構文に成長しました。
|
7
10
|
|
@@ -28,7 +31,7 @@ Slim は 不可解にならない程度に view の構文を本質的な部品
|
|
28
31
|
|
29
32
|
## リンク
|
30
33
|
|
31
|
-
* ホームページ: <http://slim-
|
34
|
+
* ホームページ: <http://github.com/slim-template/slim>
|
32
35
|
* ソース: <http://github.com/slim-template/slim>
|
33
36
|
* バグ: <http://github.com/slim-template/slim/issues>
|
34
37
|
* リスト: <http://groups.google.com/group/slim-template>
|
@@ -40,7 +43,7 @@ Slim は 不可解にならない程度に view の構文を本質的な部品
|
|
40
43
|
|
41
44
|
### Slim とは?
|
42
45
|
|
43
|
-
Slim は
|
46
|
+
Slim は __Rails5 以降__ に対応した高速, 軽量なテンプレートエンジンです。主要な Ruby の実装全てでしっかりテストされています。
|
44
47
|
私たちは継続的インテグレーションを採用しています。(travis-ci)
|
45
48
|
|
46
49
|
Slim の核となる構文は1つの考えによって導かれています: "この動作を行うために最低限必要なものは何か。"
|
@@ -408,7 +411,7 @@ body
|
|
408
411
|
タグの後に直接属性を書きます。通常の属性記述にはダブルクォート `"` か シングルクォート `'` を使わなければなりません (引用符で囲まれた属性)。
|
409
412
|
|
410
413
|
~~~ slim
|
411
|
-
a href="http://slim-
|
414
|
+
a href="http://github.com/slim-template/slim" title='Slim のホームページ' Slim のホームページへ
|
412
415
|
~~~
|
413
416
|
|
414
417
|
引用符で囲まれたテキストを属性として使えます。
|
@@ -444,7 +447,7 @@ h2 [ id = "tagline" ] = page_tagline
|
|
444
447
|
例:
|
445
448
|
|
446
449
|
~~~ slim
|
447
|
-
a href="http://slim-
|
450
|
+
a href="http://github.com/slim-template/slim" title='Slim のホームページ' Slim のホームページへ
|
448
451
|
~~~
|
449
452
|
|
450
453
|
引用符で囲まれたテキストを属性として使えます:
|
@@ -509,13 +512,13 @@ input type="text" disabled=nil
|
|
509
512
|
class 属性はスペース区切りで結合されます。
|
510
513
|
|
511
514
|
~~~ slim
|
512
|
-
a.menu class="highlight" href="http://
|
515
|
+
a.menu class="highlight" href="http://github.com/slim-template/slim/" github.com/slim-template/slim
|
513
516
|
~~~
|
514
517
|
|
515
518
|
レンダリング結果:
|
516
519
|
|
517
520
|
~~~ html
|
518
|
-
<a class="menu highlight" href="http://
|
521
|
+
<a class="menu highlight" href="http://github.com/slim-template/slim/">github.com/slim-template/slim</a>
|
519
522
|
~~~
|
520
523
|
|
521
524
|
また, `Array` を属性値として使うと、配列要素が区切り文字で結合されます。
|
@@ -568,7 +571,7 @@ div class="first second third"
|
|
568
571
|
~~~ slim
|
569
572
|
ruby:
|
570
573
|
def a_unless_current
|
571
|
-
@page_current ? {tag: 'span'} : {tag: 'a', href: 'http://
|
574
|
+
@page_current ? {tag: 'span'} : {tag: 'a', href: 'http://github.com/slim-template/slim/'}
|
572
575
|
end
|
573
576
|
- @page_current = true
|
574
577
|
*a_unless_current リンク
|
@@ -579,7 +582,7 @@ ruby:
|
|
579
582
|
レンダリング結果:
|
580
583
|
|
581
584
|
~~~ html
|
582
|
-
<span>リンク</span><a href="http://
|
585
|
+
<span>リンク</span><a href="http://github.com/slim-template/slim/">リンク</a>
|
583
586
|
~~~
|
584
587
|
|
585
588
|
### ショートカット
|
@@ -793,7 +796,7 @@ end
|
|
793
796
|
そして, 次のように使用出来ます。
|
794
797
|
|
795
798
|
~~~ slim
|
796
|
-
- links = { 'http://slim-
|
799
|
+
- links = { 'http://github.com/slim-template/slim' => 'The Slim Template Language' }
|
797
800
|
= capture link_list=:link_list, links do |url, text|
|
798
801
|
a href=url = text
|
799
802
|
~~~
|
@@ -1198,9 +1201,8 @@ Travis-CI は継続的インテグレーションテストに利用されてい
|
|
1198
1201
|
|
1199
1202
|
Slim は主要な Ruby 実装全てで動作します:
|
1200
1203
|
|
1201
|
-
* Ruby 2.
|
1202
|
-
* JRuby
|
1203
|
-
* Rubinius 2.0
|
1204
|
+
* Ruby 2.5
|
1205
|
+
* JRuby
|
1204
1206
|
|
1205
1207
|
## 貢献
|
1206
1208
|
|
@@ -1212,7 +1214,7 @@ $ git clone git://github.com/slim-template/slim
|
|
1212
1214
|
|
1213
1215
|
魔法をかけた後 pull request を送ってください。私たちは pull request が大好きです!
|
1214
1216
|
|
1215
|
-
Ruby の 2.
|
1217
|
+
Ruby の 2.5.0 でテストをすることを覚えておいてください。
|
1216
1218
|
|
1217
1219
|
もしドキュメントの不足を見つけたら, README.md をアップデートして私たちを助けて下さい。Slim に割ける時間がないが, 私たちが知っておくべきことを見つけた場合には issue を送ってください。
|
1218
1220
|
|
@@ -1228,12 +1230,9 @@ Slim は [MIT license](http://www.opensource.org/licenses/MIT) に基づいて
|
|
1228
1230
|
|
1229
1231
|
## 寄付と支援
|
1230
1232
|
|
1231
|
-
このプロジェクトをサポートしたい場合,
|
1233
|
+
このプロジェクトをサポートしたい場合, GitHub sponsors のページを見てください。
|
1232
1234
|
|
1233
|
-
[![
|
1234
|
-
[![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")
|
1235
|
-
|
1236
|
-
今のところ, 寄付はホスティング費用 (ドメインなど) に当てられる予定です。
|
1235
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
1237
1236
|
|
1238
1237
|
## 議論
|
1239
1238
|
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
-
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim)
|
4
|
-
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/slim.svg)](http://rubygems.org/gems/slim)
|
4
|
+
![Build Status](https://github.com/slim-template/slim/actions/workflows/test.yml/badge.svg)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/slim-template/slim/badges/gpa.svg)](https://codeclimate.com/github/slim-template/slim)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/slim-template/slim/badges/coverage.svg)](https://codeclimate.com/github/slim-template/slim/coverage)
|
7
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
5
8
|
|
6
9
|
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.
|
7
10
|
|
@@ -28,7 +31,7 @@ A short list of the features...
|
|
28
31
|
|
29
32
|
## Links
|
30
33
|
|
31
|
-
* Homepage: <http://slim-
|
34
|
+
* Homepage: <http://github.com/slim-template/slim>
|
32
35
|
* Source: <http://github.com/slim-template/slim>
|
33
36
|
* Bugs: <http://github.com/slim-template/slim/issues>
|
34
37
|
* List: <http://groups.google.com/group/slim-template>
|
@@ -40,7 +43,7 @@ A short list of the features...
|
|
40
43
|
|
41
44
|
### What is Slim?
|
42
45
|
|
43
|
-
Slim is a fast, lightweight templating engine with support for __Rails
|
46
|
+
Slim is a fast, lightweight templating engine with support for __Rails 5 and later__. It has been heavily tested on all major ruby implementations. We use
|
44
47
|
continuous integration (travis-ci).
|
45
48
|
|
46
49
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
@@ -59,7 +62,6 @@ by the logic less plugin and the translator plugin which provides I18n. In logic
|
|
59
62
|
* The Slim architecture is very flexible and allows you to write syntax extensions and plugins.
|
60
63
|
|
61
64
|
___Yes, Slim is speedy!___ Slim was developed right from the start with performance in mind.
|
62
|
-
Benchmarks are done for every commit at <http://travis-ci.org/slim-template/slim>.
|
63
65
|
Don't trust the numbers? That's as it should be. Please try the benchmark rake task yourself!
|
64
66
|
|
65
67
|
However in our opinion you should use Slim because of its features and syntax. We just ensure that Slim doesn't have a negative impact on the performance of your application.
|
@@ -409,7 +411,7 @@ body
|
|
409
411
|
You write attributes directly after the tag. For normal text attributes you must use double `"` or single quotes `'` (Quoted attributes).
|
410
412
|
|
411
413
|
~~~ slim
|
412
|
-
a href="http://slim-
|
414
|
+
a href="http://github.com/slim-template/slim" title='Slim Homepage' Goto the Slim homepage
|
413
415
|
~~~
|
414
416
|
|
415
417
|
You can use text interpolation in the quoted attributes.
|
@@ -445,7 +447,7 @@ h2 [ id = "tagline" ] = page_tagline
|
|
445
447
|
Example:
|
446
448
|
|
447
449
|
~~~ slim
|
448
|
-
a href="http://slim-
|
450
|
+
a href="http://github.com/slim-template/slim" title='Slim Homepage' Goto the Slim homepage
|
449
451
|
~~~
|
450
452
|
|
451
453
|
You can use text interpolation in the quoted attributes:
|
@@ -510,13 +512,13 @@ You can configure attributes to be merged if multiple are given (See option `:me
|
|
510
512
|
this is done for class attributes with the white space as delimiter.
|
511
513
|
|
512
514
|
~~~ slim
|
513
|
-
a.menu class="highlight" href="http://
|
515
|
+
a.menu class="highlight" href="http://github.com/slim-template/slim/" github.com/slim-template/slim
|
514
516
|
~~~
|
515
517
|
|
516
518
|
This renders as:
|
517
519
|
|
518
520
|
~~~ html
|
519
|
-
<a class="menu highlight" href="http://
|
521
|
+
<a class="menu highlight" href="http://github.com/slim-template/slim/">github.com/slim-template/slim</a>
|
520
522
|
~~~
|
521
523
|
|
522
524
|
You can also use an `Array` as attribute value and the array elements will be merged using the delimiter.
|
@@ -569,7 +571,7 @@ with the :tag key.
|
|
569
571
|
~~~ slim
|
570
572
|
ruby:
|
571
573
|
def a_unless_current
|
572
|
-
@page_current ? {tag: 'span'} : {tag: 'a', href: 'http://
|
574
|
+
@page_current ? {tag: 'span'} : {tag: 'a', href: 'http://github.com/slim-template/slim/'}
|
573
575
|
end
|
574
576
|
- @page_current = true
|
575
577
|
*a_unless_current Link
|
@@ -580,7 +582,7 @@ ruby:
|
|
580
582
|
This renders as:
|
581
583
|
|
582
584
|
~~~ html
|
583
|
-
<span>Link</span><a href="http://
|
585
|
+
<span>Link</span><a href="http://github.com/slim-template/slim/">Link</a>
|
584
586
|
~~~
|
585
587
|
|
586
588
|
### Shortcuts
|
@@ -794,7 +796,7 @@ end
|
|
794
796
|
and it would be used as follows
|
795
797
|
|
796
798
|
~~~ slim
|
797
|
-
- links = { 'http://slim-
|
799
|
+
- links = { 'http://github.com/slim-template/slim' => 'The Slim Template Language' }
|
798
800
|
= capture link_list=:link_list, links do |url, text|
|
799
801
|
a href=url = text
|
800
802
|
~~~
|
@@ -976,7 +978,8 @@ There are a lot of them but the good thing is, that Slim checks the configuratio
|
|
976
978
|
| Symbol | :format | :xhtml | HTML output format (Possible formats :html, :xhtml, :xml) |
|
977
979
|
| String | :attr_quote | '"' | Character to wrap attributes in html (can be ' or ") |
|
978
980
|
| Hash | :merge_attrs | \{'class' => ' '} | Joining character used if multiple html attributes are supplied (e.g. class="class1 class2") |
|
979
|
-
| Array<String> | :hyphen_attrs | %w(data) | Attributes which will be hyphenated if a Hash is given (e.g. data={
|
981
|
+
| Array<String> | :hyphen_attrs | %w(data) | Attributes which will be hyphenated if a Hash is given (e.g. data={a_foo:1,b:2} will render as data-a_foo="1" data-b="2") |
|
982
|
+
| Boolean | :hyphen_underscore_attrs | false | Attributes that have underscores in their names will be hyphenated (e.g. data={a_foo:1,b_bar:2} will render as data-a-foo="1" data-b-bar="2") |
|
980
983
|
| Boolean | :sort_attrs | true | Sort attributes by name |
|
981
984
|
| Symbol | :js_wrapper | nil | Wrap javascript by :comment, :cdata or :both. You can also :guess the wrapper based on :format. |
|
982
985
|
| Boolean | :pretty | false | Pretty HTML indenting, only block level tags are indented <b>(This is slower!)</b> |
|
@@ -1162,6 +1165,7 @@ There are plugins for various text editors (including the most important ones -
|
|
1162
1165
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
1163
1166
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
1164
1167
|
* [Atom](https://github.com/slim-template/language-slim)
|
1168
|
+
* VS Code ([Official marketplace](https://marketplace.visualstudio.com/items?itemName=sianglim.slim), [Open VSX registry](https://open-vsx.org/extension/sianglim/slim))
|
1165
1169
|
|
1166
1170
|
### Template Converters (HAML, ERB, ...)
|
1167
1171
|
|
@@ -1198,9 +1202,8 @@ Travis-CI is used for continuous integration testing: <http://travis-ci.org/slim
|
|
1198
1202
|
|
1199
1203
|
Slim is working well on all major Ruby implementations:
|
1200
1204
|
|
1201
|
-
* Ruby 2.
|
1202
|
-
* JRuby
|
1203
|
-
* Rubinius 2.0
|
1205
|
+
* Ruby 2.5 and newer
|
1206
|
+
* JRuby
|
1204
1207
|
|
1205
1208
|
## Contributing
|
1206
1209
|
|
@@ -1212,7 +1215,7 @@ $ git clone git://github.com/slim-template/slim
|
|
1212
1215
|
|
1213
1216
|
Work your magic and then submit a pull request. We love pull requests!
|
1214
1217
|
|
1215
|
-
Please remember to keep the compatibility with Ruby versions 2.
|
1218
|
+
Please remember to keep the compatibility with Ruby versions 2.5 and newer.
|
1216
1219
|
|
1217
1220
|
If you find the documentation lacking, help us out and update this README.md. If you don't have the time to work on Slim, but found something we should know about, please submit an issue.
|
1218
1221
|
|
@@ -1228,12 +1231,9 @@ Slim is released under the [MIT license](http://www.opensource.org/licenses/MIT)
|
|
1228
1231
|
|
1229
1232
|
## Donations and sponsoring
|
1230
1233
|
|
1231
|
-
If you want to support this project please visit the
|
1234
|
+
If you want to support this project please visit the GitHub sponsors page.
|
1232
1235
|
|
1233
|
-
[![
|
1234
|
-
[![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")
|
1235
|
-
|
1236
|
-
Currently the donations will be used to cover the hosting costs (domain name etc).
|
1236
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
1237
1237
|
|
1238
1238
|
## Discuss
|
1239
1239
|
|
@@ -1283,8 +1283,7 @@ Language ports/Similar languages:
|
|
1283
1283
|
* [Hamlit (High performance Haml implementation, based on Temple like Slim)](https://github.com/k0kubun/hamlit)
|
1284
1284
|
* [Faml (Faster Haml implementation, also using Temple like Slim)](https://github.com/eagletmt/faml)
|
1285
1285
|
* [Haml (Older engine which inspired Slim)](https://github.com/haml/haml)
|
1286
|
-
* [
|
1287
|
-
* [Pug (Successor of Jade, Similar engine for javascript)](https://github.com/pugjs/pug)
|
1286
|
+
* [Pug (Similar engine for javascript)](https://github.com/pugjs/pug)
|
1288
1287
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
1289
1288
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
1290
1289
|
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/Rakefile
CHANGED
@@ -11,11 +11,9 @@ task :bench, :slow do
|
|
11
11
|
ruby('benchmarks/run-benchmarks.rb')
|
12
12
|
end
|
13
13
|
|
14
|
-
task 'test' => %w(test:
|
14
|
+
task 'test' => %w(test:core test:literate test:logic_less test:translator test:smart test:include)
|
15
15
|
|
16
16
|
namespace 'test' do
|
17
|
-
task 'core_and_plugins' => %w(core literate logic_less translator smart include)
|
18
|
-
|
19
17
|
Rake::TestTask.new('core') do |t|
|
20
18
|
t.libs << 'lib' << 'test/core'
|
21
19
|
t.test_files = FileList['test/core/test_*.rb']
|
@@ -7,7 +7,7 @@ require 'context'
|
|
7
7
|
|
8
8
|
require 'benchmark/ips'
|
9
9
|
require 'tilt'
|
10
|
-
require '
|
10
|
+
require 'erubi'
|
11
11
|
require 'erb'
|
12
12
|
require 'haml'
|
13
13
|
|
@@ -25,23 +25,19 @@ class SlimBenchmarks
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def init_compiled_benches
|
28
|
-
haml = Haml::Engine.new(@haml_code, format: :html5, escape_attrs: false)
|
29
|
-
|
30
28
|
context = Context.new
|
31
29
|
|
32
|
-
haml.def_method(context, :run_haml)
|
33
30
|
context.instance_eval %{
|
34
31
|
def run_erb; #{ERB.new(@erb_code).src}; end
|
35
|
-
def
|
32
|
+
def run_erubi; #{Erubi::Engine.new(@erb_code).src}; end
|
36
33
|
def run_temple_erb; #{Temple::ERB::Engine.new.call @erb_code}; end
|
37
|
-
def run_fast_erubis; #{Erubis::FastEruby.new(@erb_code).src}; end
|
38
34
|
def run_slim_pretty; #{Slim::Engine.new(pretty: true).call @slim_code}; end
|
39
35
|
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
36
|
+
def run_haml; #{Haml::Engine.new.call @haml_code}; end
|
40
37
|
}
|
41
38
|
|
42
39
|
bench(:compiled, 'erb') { context.run_erb }
|
43
|
-
bench(:compiled, '
|
44
|
-
bench(:compiled, 'fast erubis') { context.run_fast_erubis }
|
40
|
+
bench(:compiled, 'erubi') { context.run_erubi }
|
45
41
|
bench(:compiled, 'temple erb') { context.run_temple_erb }
|
46
42
|
bench(:compiled, 'slim pretty') { context.run_slim_pretty }
|
47
43
|
bench(:compiled, 'slim ugly') { context.run_slim_ugly }
|
@@ -50,7 +46,7 @@ class SlimBenchmarks
|
|
50
46
|
|
51
47
|
def init_tilt_benches
|
52
48
|
tilt_erb = Tilt::ERBTemplate.new { @erb_code }
|
53
|
-
|
49
|
+
tilt_erubi = Tilt::ErubiTemplate.new { @erb_code }
|
54
50
|
tilt_temple_erb = Temple::ERB::Template.new { @erb_code }
|
55
51
|
tilt_haml = Tilt::HamlTemplate.new(format: :html5) { @haml_code }
|
56
52
|
tilt_slim_pretty = Slim::Template.new(pretty: true) { @slim_code }
|
@@ -59,7 +55,7 @@ class SlimBenchmarks
|
|
59
55
|
context = Context.new
|
60
56
|
|
61
57
|
bench(:tilt, 'erb') { tilt_erb.render(context) }
|
62
|
-
bench(:tilt, '
|
58
|
+
bench(:tilt, 'erubi') { tilt_erubi.render(context) }
|
63
59
|
bench(:tilt, 'temple erb') { tilt_temple_erb.render(context) }
|
64
60
|
bench(:tilt, 'slim pretty') { tilt_slim_pretty.render(context) }
|
65
61
|
bench(:tilt, 'slim ugly') { tilt_slim_ugly.render(context) }
|
@@ -71,8 +67,7 @@ class SlimBenchmarks
|
|
71
67
|
context_binding = context.instance_eval { binding }
|
72
68
|
|
73
69
|
bench(:parsing, 'erb') { ERB.new(@erb_code).result(context_binding) }
|
74
|
-
bench(:parsing, '
|
75
|
-
bench(:parsing, 'fast erubis') { Erubis::FastEruby.new(@erb_code).result(context_binding) }
|
70
|
+
bench(:parsing, 'erubi') { Erubi::Engine.new(@erb_code).result(context_binding) }
|
76
71
|
bench(:parsing, 'temple erb') { Temple::ERB::Template.new { @erb_code }.render(context) }
|
77
72
|
bench(:parsing, 'slim pretty') { Slim::Template.new(pretty: true) { @slim_code }.render(context) }
|
78
73
|
bench(:parsing, 'slim ugly') { Slim::Template.new { @slim_code }.render(context) }
|
data/doc/jp/translator.md
CHANGED
data/doc/logic_less.md
CHANGED
data/doc/translator.md
CHANGED
data/lib/slim/do_inserter.rb
CHANGED
@@ -7,7 +7,7 @@ module Slim
|
|
7
7
|
#
|
8
8
|
# @api private
|
9
9
|
class DoInserter < Filter
|
10
|
-
BLOCK_REGEX = /(\A(if|unless|else|elsif|when|begin|rescue|ensure|case)\b)|\bdo\s*(\|[^\|]*\|\s*)?\Z/
|
10
|
+
BLOCK_REGEX = /(\A(if|unless|else|elsif|when|in|begin|rescue|ensure|case)\b)|\bdo\s*(\|[^\|]*\|\s*)?\Z/
|
11
11
|
|
12
12
|
# Handle control expression `[:slim, :control, code, content]`
|
13
13
|
#
|