slim 4.1.0 → 5.1.1
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 +32 -7
- data/Gemfile +15 -41
- data/LICENSE +1 -1
- data/README.jp.md +22 -25
- data/README.md +61 -29
- data/Rakefile +1 -8
- data/doc/jp/translator.md +1 -1
- data/doc/logic_less.md +1 -1
- data/doc/translator.md +1 -1
- data/lib/slim/code_attributes.rb +1 -0
- data/lib/slim/command.rb +1 -7
- data/lib/slim/controls.rb +1 -0
- data/lib/slim/do_inserter.rb +2 -1
- data/lib/slim/embedded.rb +14 -12
- data/lib/slim/end_inserter.rb +3 -2
- data/lib/slim/engine.rb +3 -0
- data/lib/slim/erb_converter.rb +1 -0
- data/lib/slim/filter.rb +1 -0
- data/lib/slim/grammar.rb +1 -0
- data/lib/slim/include.rb +1 -0
- data/lib/slim/interpolation.rb +1 -0
- data/lib/slim/logic_less/context.rb +2 -1
- data/lib/slim/logic_less/filter.rb +1 -0
- data/lib/slim/logic_less.rb +1 -0
- data/lib/slim/parser.rb +21 -34
- data/lib/slim/railtie.rb +18 -0
- data/lib/slim/smart/escaper.rb +1 -0
- data/lib/slim/smart/filter.rb +1 -0
- data/lib/slim/smart/parser.rb +1 -0
- data/lib/slim/smart.rb +1 -0
- data/lib/slim/splat/builder.rb +9 -2
- data/lib/slim/splat/filter.rb +3 -1
- data/lib/slim/template.rb +1 -14
- data/lib/slim/translator.rb +3 -2
- data/lib/slim/version.rb +2 -1
- data/lib/slim.rb +2 -0
- data/slim.gemspec +4 -5
- data/test/core/helper.rb +1 -1
- 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_encoding.rb +2 -2
- data/test/core/test_erb_converter.rb +4 -6
- data/test/core/test_html_attributes.rb +8 -0
- data/test/core/test_html_structure.rb +54 -0
- data/test/core/test_pretty.rb +4 -7
- data/test/literate/TESTS.md +72 -22
- data/test/literate/run.rb +3 -3
- data/test/rails/app/controllers/slim_controller.rb +2 -1
- data/test/rails/app/views/slim/attributes.html.slim +3 -0
- data/test/rails/config/application.rb +0 -17
- data/test/rails/test/test_slim.rb +11 -12
- data/test/sinatra/helper.rb +0 -2
- metadata +14 -33
- data/.travis.yml +0 -38
- data/benchmarks/context.rb +0 -11
- data/benchmarks/profile-parser.rb +0 -10
- data/benchmarks/profile-render.rb +0 -12
- data/benchmarks/run-benchmarks.rb +0 -120
- data/benchmarks/run-diffbench.rb +0 -21
- data/benchmarks/view.erb +0 -25
- data/benchmarks/view.haml +0 -20
- data/benchmarks/view.slim +0 -19
- 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: 032ed4e8911b32aa669a7e0a6196a9955d2f2cdadbcc8432aa589039bc3a7b50
|
4
|
+
data.tar.gz: 94ce4618acbca850dce85c0ce3379e77a8b03ca846b84edcb25a09dfa050e848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25e4b9230e092183013063ece1dbb3233b267eb118f90e41dca7d4a2221fe4e00b1c572d6d1b5defac7b0912bba0b00ff442785c930f49f06849819d699ecb7
|
7
|
+
data.tar.gz: 065b7317b43379f0c7ecf85a0ce4fd398b9ecac13e3b6793de9293711776468bd24c15b2a19f029dd04a16aaf724b1210e0fab600a06a23db57f172054d7f798
|
@@ -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: "0 15 * * 0"
|
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,28 @@
|
|
1
|
+
5.1.1 (2023-05-16)
|
2
|
+
|
3
|
+
* Support lambda functions as shortcuts - #677 #813 #903
|
4
|
+
* Support --enable-frozen-string-literal - #851
|
5
|
+
|
6
|
+
5.1.0 (2023-03-06)
|
7
|
+
|
8
|
+
* Allow whitespace markers for verbatim text: `|<`, `|>`, and `|<>` - #912
|
9
|
+
* Do not swallow single quote after output line indicator - #911
|
10
|
+
* Support Tilt 2.1.0 - #910
|
11
|
+
* Fix Railtie load error - #904
|
12
|
+
* Fix attribute parsing with square brackets - #796
|
13
|
+
|
14
|
+
5.0.0 (2023-01-23)
|
15
|
+
|
16
|
+
* Fix markdown interpolation #773
|
17
|
+
* Support case/in #884
|
18
|
+
* Extract slim/railtie #850
|
19
|
+
* css: doesn't add type='text/css' anymore #828
|
20
|
+
* Remove deprecated whitespace syntax =' etc
|
21
|
+
* Add support for annotate_rendered_view_with_filenames #867, #878, #901
|
22
|
+
* Remove deprecated syntax
|
23
|
+
* Add option to hyphenate underscore attributes - #852
|
24
|
+
* Update CI/CD testing and dependencies
|
25
|
+
|
1
26
|
4.1.0 (2020-05-07)
|
2
27
|
* Add support for Tailwind CSS - #841
|
3
28
|
* Update dependencies and testing
|
@@ -120,10 +145,10 @@
|
|
120
145
|
div id=('obj' + name) data={:a => 1, :b => 2} class=['alpha', 'beta']
|
121
146
|
* Quoted attributes are escaped by default
|
122
147
|
Old:
|
123
|
-
a href='http://slim-
|
148
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
124
149
|
New:
|
125
|
-
a href='http://slim-
|
126
|
-
a href=='http://slim-
|
150
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
151
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
127
152
|
You can always disable escaping completly by using :disable_escape if you don't want to write '=='.
|
128
153
|
* Added hyphenation support for data attributes (Option :hyphen_attrs)
|
129
154
|
Example: div data={key1_key2: 2, key1: {key3: 3}} will render as '<div data-key1-key2="2" data-key1-key3="3"></div>'
|
@@ -164,11 +189,11 @@
|
|
164
189
|
* Deprecated :escape_quoted_attrs (done by default in 2.0)
|
165
190
|
* Warn if quoted attributes might be double escaped in Slim 2.0.0
|
166
191
|
Old syntax:
|
167
|
-
a href='http://slim-
|
168
|
-
a href=='http://slim-
|
192
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
193
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
169
194
|
New syntax in 2.0.0:
|
170
|
-
a href='http://slim-
|
171
|
-
a href=='http://slim-
|
195
|
+
a href='http://github.com/slim-template/slim/?a=1&b=2'
|
196
|
+
a href=='http://github.com/slim-template/slim/?a=1&b=2'
|
172
197
|
* Improved pretty printing (Issue #202)
|
173
198
|
* Renamed Slim::EmbeddedEngine to Slim::Embedded (Old constant still available until 2.0)
|
174
199
|
* Renamed Slim::ControlStructures to Slim::Controls
|
data/Gemfile
CHANGED
@@ -2,22 +2,15 @@ source 'https://rubygems.org/'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem '
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
if ENV['TRAVIS']
|
17
|
-
gem 'rails-controller-testing'
|
18
|
-
end
|
19
|
-
|
20
|
-
if ENV['TEMPLE'] == 'master'
|
5
|
+
gem 'test-unit', '~> 3.5'
|
6
|
+
gem 'minitest', '~> 5.15'
|
7
|
+
gem 'rake', '~> 13.0'
|
8
|
+
gem 'kramdown', '~> 2.4'
|
9
|
+
|
10
|
+
if ENV['TEMPLE'] && ENV['TEMPLE'] != 'master'
|
11
|
+
gem 'temple', "= #{ENV['TEMPLE']}"
|
12
|
+
else
|
13
|
+
# Test against temple master by default
|
21
14
|
gem 'temple', :github => 'judofyr/temple'
|
22
15
|
end
|
23
16
|
|
@@ -30,41 +23,22 @@ if ENV['TILT']
|
|
30
23
|
end
|
31
24
|
|
32
25
|
if ENV['RAILS']
|
26
|
+
gem 'rails-controller-testing'
|
27
|
+
|
33
28
|
# we need some smarter test logic for the different Rails versions
|
34
|
-
if ENV['RAILS'] == '
|
35
|
-
gem 'rails', :github => 'rails/rails'
|
29
|
+
if ENV['RAILS'] == 'main'
|
30
|
+
gem 'rails', :github => 'rails/rails', branch: 'main'
|
36
31
|
else
|
37
32
|
gem 'rails', "= #{ENV['RAILS']}"
|
38
33
|
end
|
39
|
-
|
40
|
-
gem 'slim-rails', require: false
|
41
|
-
end
|
42
|
-
|
43
|
-
gem 'test-unit', '~> 3.3', '>= 3.3.5'
|
44
|
-
gem 'minitest', '~> 5.14'
|
45
|
-
|
46
|
-
if RUBY_ENGINE == 'rbx' && !ENV['TRAVIS']
|
47
|
-
gem 'psych'
|
48
34
|
end
|
49
35
|
|
50
36
|
if ENV['SINATRA']
|
37
|
+
gem 'rack-test'
|
38
|
+
|
51
39
|
if ENV['SINATRA'] == 'master'
|
52
40
|
gem 'sinatra', :github => 'sinatra/sinatra'
|
53
41
|
else
|
54
42
|
gem 'sinatra', :tag => "v#{ENV['SINATRA']}"
|
55
43
|
end
|
56
44
|
end
|
57
|
-
|
58
|
-
gem 'rake', '~> 13.0', '>= 13.0.1'
|
59
|
-
gem 'sassc', '~> 2.2', '>= 2.2.1'
|
60
|
-
gem 'kramdown', '~> 2.1'
|
61
|
-
|
62
|
-
if ENV['TASK'] == 'bench'
|
63
|
-
gem 'benchmark-ips'
|
64
|
-
gem 'erubis'
|
65
|
-
gem 'haml'
|
66
|
-
end
|
67
|
-
|
68
|
-
if ENV['CODECLIMATE_REPO_TOKEN']
|
69
|
-
gem 'codeclimate-test-reporter'
|
70
|
-
end
|
data/LICENSE
CHANGED
data/README.jp.md
CHANGED
@@ -1,7 +1,8 @@
|
|
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
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
5
6
|
|
6
7
|
Slim は 不可解にならない程度に view の構文を本質的な部品まで減らすことを目指したテンプレート言語です。標準的な HTML テンプレートからどれだけのものを減らせるか、検証するところから始まりました。(<, >, 閉じタグなど) 多くの人が Slim に興味を持ったことで, 機能的で柔軟な構文に成長しました。
|
7
8
|
|
@@ -28,19 +29,19 @@ Slim は 不可解にならない程度に view の構文を本質的な部品
|
|
28
29
|
|
29
30
|
## リンク
|
30
31
|
|
31
|
-
* ホームページ: <
|
32
|
-
* ソース: <
|
33
|
-
* バグ: <
|
34
|
-
* リスト: <
|
32
|
+
* ホームページ: <https://slim-template.github.io>
|
33
|
+
* ソース: <https://github.com/slim-template/slim>
|
34
|
+
* バグ: <https://github.com/slim-template/slim/issues>
|
35
|
+
* リスト: <https://groups.google.com/group/slim-template>
|
35
36
|
* API ドキュメント:
|
36
|
-
* 最新の Gem: <
|
37
|
-
* GitHub master: <
|
37
|
+
* 最新の Gem: <https://rubydoc.info/gems/slim/frames> <https://www.omniref.com/ruby/gems/slim>
|
38
|
+
* GitHub master: <https://rubydoc.info/github/slim-template/slim/master/frames> <https://www.omniref.com/github/slim-template/slim>
|
38
39
|
|
39
40
|
## イントロダクション
|
40
41
|
|
41
42
|
### Slim とは?
|
42
43
|
|
43
|
-
Slim は
|
44
|
+
Slim は __Rails5 以降__ に対応した高速, 軽量なテンプレートエンジンです。主要な Ruby の実装全てでしっかりテストされています。
|
44
45
|
私たちは継続的インテグレーションを採用しています。(travis-ci)
|
45
46
|
|
46
47
|
Slim の核となる構文は1つの考えによって導かれています: "この動作を行うために最低限必要なものは何か。"
|
@@ -408,7 +409,7 @@ body
|
|
408
409
|
タグの後に直接属性を書きます。通常の属性記述にはダブルクォート `"` か シングルクォート `'` を使わなければなりません (引用符で囲まれた属性)。
|
409
410
|
|
410
411
|
~~~ slim
|
411
|
-
a href="
|
412
|
+
a href="https://slim-template.github.io" title='Slim のホームページ' Slim のホームページへ
|
412
413
|
~~~
|
413
414
|
|
414
415
|
引用符で囲まれたテキストを属性として使えます。
|
@@ -444,7 +445,7 @@ h2 [ id = "tagline" ] = page_tagline
|
|
444
445
|
例:
|
445
446
|
|
446
447
|
~~~ slim
|
447
|
-
a href="
|
448
|
+
a href="https://slim-template.github.io" title='Slim のホームページ' Slim のホームページへ
|
448
449
|
~~~
|
449
450
|
|
450
451
|
引用符で囲まれたテキストを属性として使えます:
|
@@ -509,13 +510,13 @@ input type="text" disabled=nil
|
|
509
510
|
class 属性はスペース区切りで結合されます。
|
510
511
|
|
511
512
|
~~~ slim
|
512
|
-
a.menu class="highlight" href="
|
513
|
+
a.menu class="highlight" href="https://slim-template.github.io/" slim-template.github.io
|
513
514
|
~~~
|
514
515
|
|
515
516
|
レンダリング結果:
|
516
517
|
|
517
518
|
~~~ html
|
518
|
-
<a class="menu highlight" href="
|
519
|
+
<a class="menu highlight" href="https://slim-template.github.io/">slim-template.github.io</a>
|
519
520
|
~~~
|
520
521
|
|
521
522
|
また, `Array` を属性値として使うと、配列要素が区切り文字で結合されます。
|
@@ -568,7 +569,7 @@ div class="first second third"
|
|
568
569
|
~~~ slim
|
569
570
|
ruby:
|
570
571
|
def a_unless_current
|
571
|
-
@page_current ? {tag: 'span'} : {tag: 'a', href: '
|
572
|
+
@page_current ? {tag: 'span'} : {tag: 'a', href: 'https://slim-template.github.io/'}
|
572
573
|
end
|
573
574
|
- @page_current = true
|
574
575
|
*a_unless_current リンク
|
@@ -579,7 +580,7 @@ ruby:
|
|
579
580
|
レンダリング結果:
|
580
581
|
|
581
582
|
~~~ html
|
582
|
-
<span>リンク</span><a href="
|
583
|
+
<span>リンク</span><a href="https://slim-template.github.io/">リンク</a>
|
583
584
|
~~~
|
584
585
|
|
585
586
|
### ショートカット
|
@@ -793,7 +794,7 @@ end
|
|
793
794
|
そして, 次のように使用出来ます。
|
794
795
|
|
795
796
|
~~~ slim
|
796
|
-
- links = { '
|
797
|
+
- links = { 'https://slim-template.github.io' => 'The Slim Template Language' }
|
797
798
|
= capture link_list=:link_list, links do |url, text|
|
798
799
|
a href=url = text
|
799
800
|
~~~
|
@@ -1198,9 +1199,8 @@ Travis-CI は継続的インテグレーションテストに利用されてい
|
|
1198
1199
|
|
1199
1200
|
Slim は主要な Ruby 実装全てで動作します:
|
1200
1201
|
|
1201
|
-
* Ruby 2.
|
1202
|
-
* JRuby
|
1203
|
-
* Rubinius 2.0
|
1202
|
+
* Ruby 2.5
|
1203
|
+
* JRuby
|
1204
1204
|
|
1205
1205
|
## 貢献
|
1206
1206
|
|
@@ -1212,7 +1212,7 @@ $ git clone git://github.com/slim-template/slim
|
|
1212
1212
|
|
1213
1213
|
魔法をかけた後 pull request を送ってください。私たちは pull request が大好きです!
|
1214
1214
|
|
1215
|
-
Ruby の 2.
|
1215
|
+
Ruby の 2.5.0 でテストをすることを覚えておいてください。
|
1216
1216
|
|
1217
1217
|
もしドキュメントの不足を見つけたら, README.md をアップデートして私たちを助けて下さい。Slim に割ける時間がないが, 私たちが知っておくべきことを見つけた場合には issue を送ってください。
|
1218
1218
|
|
@@ -1228,12 +1228,9 @@ Slim は [MIT license](http://www.opensource.org/licenses/MIT) に基づいて
|
|
1228
1228
|
|
1229
1229
|
## 寄付と支援
|
1230
1230
|
|
1231
|
-
このプロジェクトをサポートしたい場合,
|
1231
|
+
このプロジェクトをサポートしたい場合, GitHub sponsors のページを見てください。
|
1232
1232
|
|
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
|
-
今のところ, 寄付はホスティング費用 (ドメインなど) に当てられる予定です。
|
1233
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
1237
1234
|
|
1238
1235
|
## 議論
|
1239
1236
|
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
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
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
5
6
|
|
6
7
|
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
8
|
|
@@ -28,19 +29,19 @@ A short list of the features...
|
|
28
29
|
|
29
30
|
## Links
|
30
31
|
|
31
|
-
* Homepage: <
|
32
|
-
* Source: <
|
33
|
-
* Bugs: <
|
34
|
-
* List: <
|
32
|
+
* Homepage: <https://slim-template.github.io>
|
33
|
+
* Source: <https://github.com/slim-template/slim>
|
34
|
+
* Bugs: <https://github.com/slim-template/slim/issues>
|
35
|
+
* List: <https://groups.google.com/group/slim-template>
|
35
36
|
* API documentation:
|
36
|
-
* Latest Gem: <
|
37
|
-
* GitHub master: <
|
37
|
+
* Latest Gem: <https://rubydoc.info/gems/slim/frames> <https://www.omniref.com/ruby/gems/slim>
|
38
|
+
* GitHub master: <https://rubydoc.info/github/slim-template/slim/master/frames> <https://www.omniref.com/github/slim-template/slim>
|
38
39
|
|
39
40
|
## Introduction
|
40
41
|
|
41
42
|
### What is Slim?
|
42
43
|
|
43
|
-
Slim is a fast, lightweight templating engine with support for __Rails
|
44
|
+
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
45
|
continuous integration (travis-ci).
|
45
46
|
|
46
47
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
@@ -59,7 +60,6 @@ by the logic less plugin and the translator plugin which provides I18n. In logic
|
|
59
60
|
* The Slim architecture is very flexible and allows you to write syntax extensions and plugins.
|
60
61
|
|
61
62
|
___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
63
|
Don't trust the numbers? That's as it should be. Please try the benchmark rake task yourself!
|
64
64
|
|
65
65
|
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.
|
@@ -153,6 +153,17 @@ You can also embed html in the text line
|
|
153
153
|
| <tr><td>#{a.name}</td><td>#{a.description}</td></tr>
|
154
154
|
~~~
|
155
155
|
|
156
|
+
#### Verbatim text with leading and/or trailing white space `|<` `|>` `|<>`
|
157
|
+
|
158
|
+
You can add white space around verbatim text in the same way as for `=` output:
|
159
|
+
~~~ slim
|
160
|
+
| This line will not have any extra white space.
|
161
|
+
| This line will have a leading space, but it is difficult to see.
|
162
|
+
|< This line will have a leading white space.
|
163
|
+
|> This line will have a trailing white space.
|
164
|
+
|<> This line will have both leading and trailing white space.
|
165
|
+
~~~
|
166
|
+
|
156
167
|
### Verbatim text with trailing white space `'`
|
157
168
|
|
158
169
|
The single quote tells Slim to copy the line (similar to `|`), but makes sure that a single trailing white space is appended.
|
@@ -409,7 +420,7 @@ body
|
|
409
420
|
You write attributes directly after the tag. For normal text attributes you must use double `"` or single quotes `'` (Quoted attributes).
|
410
421
|
|
411
422
|
~~~ slim
|
412
|
-
a href="
|
423
|
+
a href="https://slim-template.github.io" title='Slim Homepage' Goto the Slim homepage
|
413
424
|
~~~
|
414
425
|
|
415
426
|
You can use text interpolation in the quoted attributes.
|
@@ -445,7 +456,7 @@ h2 [ id = "tagline" ] = page_tagline
|
|
445
456
|
Example:
|
446
457
|
|
447
458
|
~~~ slim
|
448
|
-
a href="
|
459
|
+
a href="https://slim-template.github.io" title='Slim Homepage' Goto the Slim homepage
|
449
460
|
~~~
|
450
461
|
|
451
462
|
You can use text interpolation in the quoted attributes:
|
@@ -510,13 +521,13 @@ You can configure attributes to be merged if multiple are given (See option `:me
|
|
510
521
|
this is done for class attributes with the white space as delimiter.
|
511
522
|
|
512
523
|
~~~ slim
|
513
|
-
a.menu class="highlight" href="
|
524
|
+
a.menu class="highlight" href="https://slim-template.github.io/" slim-template.github.io
|
514
525
|
~~~
|
515
526
|
|
516
527
|
This renders as:
|
517
528
|
|
518
529
|
~~~ html
|
519
|
-
<a class="menu highlight" href="
|
530
|
+
<a class="menu highlight" href="https://slim-template.github.io/">slim-template.github.io</a>
|
520
531
|
~~~
|
521
532
|
|
522
533
|
You can also use an `Array` as attribute value and the array elements will be merged using the delimiter.
|
@@ -569,7 +580,7 @@ with the :tag key.
|
|
569
580
|
~~~ slim
|
570
581
|
ruby:
|
571
582
|
def a_unless_current
|
572
|
-
@page_current ? {tag: 'span'} : {tag: 'a', href: '
|
583
|
+
@page_current ? {tag: 'span'} : {tag: 'a', href: 'https://slim-template.github.io/'}
|
573
584
|
end
|
574
585
|
- @page_current = true
|
575
586
|
*a_unless_current Link
|
@@ -580,7 +591,7 @@ ruby:
|
|
580
591
|
This renders as:
|
581
592
|
|
582
593
|
~~~ html
|
583
|
-
<span>Link</span><a href="
|
594
|
+
<span>Link</span><a href="https://slim-template.github.io/">Link</a>
|
584
595
|
~~~
|
585
596
|
|
586
597
|
### Shortcuts
|
@@ -690,6 +701,30 @@ which renders to
|
|
690
701
|
</script>
|
691
702
|
~~~
|
692
703
|
|
704
|
+
#### Lambda shortcuts
|
705
|
+
|
706
|
+
You can define custom shortcuts using lambdas.
|
707
|
+
|
708
|
+
In this example we add `~` to create a shortcut with a special processing (adding a prefix) for the class attribute.
|
709
|
+
|
710
|
+
~~~ ruby
|
711
|
+
Slim::Engine.set_options shortcut: {'~' => {attr: ->(v) {{class: "styled-#{v}"}}}}
|
712
|
+
~~~
|
713
|
+
|
714
|
+
We can use it in Slim code like this
|
715
|
+
|
716
|
+
~~~ slim
|
717
|
+
h1~title Hello
|
718
|
+
~text~question.paragraph How are you?
|
719
|
+
~~~
|
720
|
+
|
721
|
+
which renders to
|
722
|
+
|
723
|
+
~~~ html
|
724
|
+
<h1 class="styled-title">Hello</h1>
|
725
|
+
<div class="styled-text styled-question paragraph">How are you?</div>
|
726
|
+
~~~
|
727
|
+
|
693
728
|
#### ID shortcut `#` and class shortcut `.`
|
694
729
|
|
695
730
|
You can specify the `id` and `class` attributes in the following shortcut form
|
@@ -794,7 +829,7 @@ end
|
|
794
829
|
and it would be used as follows
|
795
830
|
|
796
831
|
~~~ slim
|
797
|
-
- links = { '
|
832
|
+
- links = { 'https://slim-template.github.io' => 'The Slim Template Language' }
|
798
833
|
= capture link_list=:link_list, links do |url, text|
|
799
834
|
a href=url = text
|
800
835
|
~~~
|
@@ -976,7 +1011,8 @@ There are a lot of them but the good thing is, that Slim checks the configuratio
|
|
976
1011
|
| Symbol | :format | :xhtml | HTML output format (Possible formats :html, :xhtml, :xml) |
|
977
1012
|
| String | :attr_quote | '"' | Character to wrap attributes in html (can be ' or ") |
|
978
1013
|
| 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={
|
1014
|
+
| 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") |
|
1015
|
+
| 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
1016
|
| Boolean | :sort_attrs | true | Sort attributes by name |
|
981
1017
|
| Symbol | :js_wrapper | nil | Wrap javascript by :comment, :cdata or :both. You can also :guess the wrapper based on :format. |
|
982
1018
|
| Boolean | :pretty | false | Pretty HTML indenting, only block level tags are indented <b>(This is slower!)</b> |
|
@@ -1162,6 +1198,7 @@ There are plugins for various text editors (including the most important ones -
|
|
1162
1198
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
1163
1199
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
1164
1200
|
* [Atom](https://github.com/slim-template/language-slim)
|
1201
|
+
* VS Code ([Official marketplace](https://marketplace.visualstudio.com/items?itemName=sianglim.slim), [Open VSX registry](https://open-vsx.org/extension/sianglim/slim))
|
1165
1202
|
|
1166
1203
|
### Template Converters (HAML, ERB, ...)
|
1167
1204
|
|
@@ -1198,9 +1235,8 @@ Travis-CI is used for continuous integration testing: <http://travis-ci.org/slim
|
|
1198
1235
|
|
1199
1236
|
Slim is working well on all major Ruby implementations:
|
1200
1237
|
|
1201
|
-
* Ruby 2.
|
1202
|
-
* JRuby
|
1203
|
-
* Rubinius 2.0
|
1238
|
+
* Ruby 2.5 and newer
|
1239
|
+
* JRuby
|
1204
1240
|
|
1205
1241
|
## Contributing
|
1206
1242
|
|
@@ -1212,7 +1248,7 @@ $ git clone git://github.com/slim-template/slim
|
|
1212
1248
|
|
1213
1249
|
Work your magic and then submit a pull request. We love pull requests!
|
1214
1250
|
|
1215
|
-
Please remember to keep the compatibility with Ruby versions 2.
|
1251
|
+
Please remember to keep the compatibility with Ruby versions 2.5 and newer.
|
1216
1252
|
|
1217
1253
|
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
1254
|
|
@@ -1228,12 +1264,9 @@ Slim is released under the [MIT license](http://www.opensource.org/licenses/MIT)
|
|
1228
1264
|
|
1229
1265
|
## Donations and sponsoring
|
1230
1266
|
|
1231
|
-
If you want to support this project please visit the
|
1232
|
-
|
1233
|
-
[![Gittip donate button](https://img.shields.io/gratipay/bevry.svg)](https://www.gittip.com/min4d/ "Donate weekly to this project using Gittip")
|
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")
|
1267
|
+
If you want to support this project please visit the GitHub sponsors page.
|
1235
1268
|
|
1236
|
-
|
1269
|
+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/slim-template)](https://github.com/sponsors/slim-template)
|
1237
1270
|
|
1238
1271
|
## Discuss
|
1239
1272
|
|
@@ -1283,8 +1316,7 @@ Language ports/Similar languages:
|
|
1283
1316
|
* [Hamlit (High performance Haml implementation, based on Temple like Slim)](https://github.com/k0kubun/hamlit)
|
1284
1317
|
* [Faml (Faster Haml implementation, also using Temple like Slim)](https://github.com/eagletmt/faml)
|
1285
1318
|
* [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)
|
1319
|
+
* [Pug (Similar engine for javascript)](https://github.com/pugjs/pug)
|
1288
1320
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
1289
1321
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
1290
1322
|
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/Rakefile
CHANGED
@@ -6,16 +6,9 @@ end
|
|
6
6
|
|
7
7
|
require 'rake/testtask'
|
8
8
|
|
9
|
-
|
10
|
-
task :bench, :slow do
|
11
|
-
ruby('benchmarks/run-benchmarks.rb')
|
12
|
-
end
|
13
|
-
|
14
|
-
task 'test' => %w(test:core_and_plugins)
|
9
|
+
task 'test' => %w(test:core test:literate test:logic_less test:translator test:smart test:include)
|
15
10
|
|
16
11
|
namespace 'test' do
|
17
|
-
task 'core_and_plugins' => %w(core literate logic_less translator smart include)
|
18
|
-
|
19
12
|
Rake::TestTask.new('core') do |t|
|
20
13
|
t.libs << 'lib' << 'test/core'
|
21
14
|
t.test_files = FileList['test/core/test_*.rb']
|
data/doc/jp/translator.md
CHANGED
data/doc/logic_less.md
CHANGED
data/doc/translator.md
CHANGED
data/lib/slim/code_attributes.rb
CHANGED
data/lib/slim/command.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'slim'
|
2
3
|
require 'optparse'
|
3
4
|
|
@@ -63,13 +64,6 @@ module Slim
|
|
63
64
|
eval(locals)
|
64
65
|
else
|
65
66
|
require 'yaml'
|
66
|
-
if RUBY_ENGINE == 'rbx'
|
67
|
-
begin
|
68
|
-
require 'psych'
|
69
|
-
rescue LoadError
|
70
|
-
$stderr.puts 'Please install psych gem as Rubunius ships with an old YAML engine.'
|
71
|
-
end
|
72
|
-
end
|
73
67
|
YAML.load(locals)
|
74
68
|
end
|
75
69
|
end
|
data/lib/slim/controls.rb
CHANGED