slim 4.1.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +51 -0
  3. data/.yardopts +1 -1
  4. data/CHANGES +32 -7
  5. data/Gemfile +15 -41
  6. data/LICENSE +1 -1
  7. data/README.jp.md +22 -25
  8. data/README.md +61 -29
  9. data/Rakefile +1 -8
  10. data/doc/jp/translator.md +1 -1
  11. data/doc/logic_less.md +1 -1
  12. data/doc/translator.md +1 -1
  13. data/lib/slim/code_attributes.rb +1 -0
  14. data/lib/slim/command.rb +1 -7
  15. data/lib/slim/controls.rb +1 -0
  16. data/lib/slim/do_inserter.rb +2 -1
  17. data/lib/slim/embedded.rb +14 -12
  18. data/lib/slim/end_inserter.rb +3 -2
  19. data/lib/slim/engine.rb +3 -0
  20. data/lib/slim/erb_converter.rb +1 -0
  21. data/lib/slim/filter.rb +1 -0
  22. data/lib/slim/grammar.rb +1 -0
  23. data/lib/slim/include.rb +1 -0
  24. data/lib/slim/interpolation.rb +1 -0
  25. data/lib/slim/logic_less/context.rb +2 -1
  26. data/lib/slim/logic_less/filter.rb +1 -0
  27. data/lib/slim/logic_less.rb +1 -0
  28. data/lib/slim/parser.rb +21 -34
  29. data/lib/slim/railtie.rb +18 -0
  30. data/lib/slim/smart/escaper.rb +1 -0
  31. data/lib/slim/smart/filter.rb +1 -0
  32. data/lib/slim/smart/parser.rb +1 -0
  33. data/lib/slim/smart.rb +1 -0
  34. data/lib/slim/splat/builder.rb +9 -2
  35. data/lib/slim/splat/filter.rb +3 -1
  36. data/lib/slim/template.rb +1 -14
  37. data/lib/slim/translator.rb +3 -2
  38. data/lib/slim/version.rb +2 -1
  39. data/lib/slim.rb +2 -0
  40. data/slim.gemspec +4 -5
  41. data/test/core/helper.rb +1 -1
  42. data/test/core/test_code_evaluation.rb +1 -0
  43. data/test/core/test_code_structure.rb +17 -0
  44. data/test/core/test_commands.rb +8 -7
  45. data/test/core/test_embedded_engines.rb +18 -14
  46. data/test/core/test_encoding.rb +2 -2
  47. data/test/core/test_erb_converter.rb +4 -6
  48. data/test/core/test_html_attributes.rb +8 -0
  49. data/test/core/test_html_structure.rb +54 -0
  50. data/test/core/test_pretty.rb +4 -7
  51. data/test/literate/TESTS.md +72 -22
  52. data/test/literate/run.rb +3 -3
  53. data/test/rails/app/controllers/slim_controller.rb +2 -1
  54. data/test/rails/app/views/slim/attributes.html.slim +3 -0
  55. data/test/rails/config/application.rb +0 -17
  56. data/test/rails/test/test_slim.rb +11 -12
  57. data/test/sinatra/helper.rb +0 -2
  58. metadata +14 -33
  59. data/.travis.yml +0 -38
  60. data/benchmarks/context.rb +0 -11
  61. data/benchmarks/profile-parser.rb +0 -10
  62. data/benchmarks/profile-render.rb +0 -12
  63. data/benchmarks/run-benchmarks.rb +0 -120
  64. data/benchmarks/run-diffbench.rb +0 -21
  65. data/benchmarks/view.erb +0 -25
  66. data/benchmarks/view.haml +0 -20
  67. data/benchmarks/view.slim +0 -19
  68. 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: 374bad17fd98e439f41336ea3a634afd4e918708803ada3d211071e565d3ba34
4
- data.tar.gz: 94a7178a4263ec906413f4f5ce921fa2ddb12423fcd6e28bbb8fbd456bc2ebb5
3
+ metadata.gz: 032ed4e8911b32aa669a7e0a6196a9955d2f2cdadbcc8432aa589039bc3a7b50
4
+ data.tar.gz: 94ce4618acbca850dce85c0ce3379e77a8b03ca846b84edcb25a09dfa050e848
5
5
  SHA512:
6
- metadata.gz: 282bb0085cd7e91ddffbc4fc9af6ab82ec4478ef2090a82592bf96a395f2ad172c6af9f1010f5e0e9cee57281c487e5e2bb4b25a75e2eac0df02018bc298faf9
7
- data.tar.gz: 7924d7af215643a8207b738f3f97c46f32bb990db7a103987f14b8b9558ec7de9208aaf27c65840d7caa7d60c156e56f6f876dd7ff54190da91fc436ccc75842
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
@@ -1,4 +1,4 @@
1
1
  --markup-provider redcarpet
2
2
  --markup markdown
3
- - README.md CHANGES LICENSE test/literate/TESTS.md doc/logic_less.md doc/translator.md doc/smart.md
3
+ - README.md CHANGES LICENSE test/literate/TESTS.md doc/logic_less.md doc/translator.md doc/smart.md doc/include.md
4
4
 
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-lang.com/?a=1&amp;b=2'
148
+ a href='http://github.com/slim-template/slim/?a=1&amp;b=2'
124
149
  New:
125
- a href='http://slim-lang.com/?a=1&b=2'
126
- a href=='http://slim-lang.com/?a=1&amp;b=2'
150
+ a href='http://github.com/slim-template/slim/?a=1&b=2'
151
+ a href=='http://github.com/slim-template/slim/?a=1&amp;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-lang.com/?a=1&amp;b=2'
168
- a href=='http://slim-lang.com/?a=1&amp;b=2'
192
+ a href='http://github.com/slim-template/slim/?a=1&amp;b=2'
193
+ a href=='http://github.com/slim-template/slim/?a=1&amp;b=2'
169
194
  New syntax in 2.0.0:
170
- a href='http://slim-lang.com/?a=1&b=2'
171
- a href=='http://slim-lang.com/?a=1&amp;b=2'
195
+ a href='http://github.com/slim-template/slim/?a=1&b=2'
196
+ a href=='http://github.com/slim-template/slim/?a=1&amp;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
- 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'
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'] == 'master'
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
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2010 - 2016 Slim Team
3
+ Copyright (c) 2010 - 2023 Slim Team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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) [![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
- [![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")
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
- * ホームページ: <http://slim-lang.com>
32
- * ソース: <http://github.com/slim-template/slim>
33
- * バグ: <http://github.com/slim-template/slim/issues>
34
- * リスト: <http://groups.google.com/group/slim-template>
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: <http://rubydoc.info/gems/slim/frames> <https://www.omniref.com/ruby/gems/slim>
37
- * GitHub master: <http://rubydoc.info/github/slim-template/slim/master/frames> <https://www.omniref.com/github/slim-template/slim>
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 は __Rails3 以降__ に対応した高速, 軽量なテンプレートエンジンです。主要な Ruby の実装全てでしっかりテストされています。
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="http://slim-lang.com" title='Slim のホームページ' Slim のホームページへ
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="http://slim-lang.com" title='Slim のホームページ' Slim のホームページへ
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="http://slim-lang.com/" Slim-lang.com
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="http://slim-lang.com/">Slim-lang.com</a>
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: 'http://slim-lang.com/'}
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="http://slim-lang.com/">リンク</a>
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 = { 'http://slim-lang.com' => 'The Slim Template Language' }
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.0, 2.1, 2.2 および 2.3
1202
- * JRuby 1.9 mode
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.3.0, 2.2.0, 2.1.0 と 2.0.0 でテストをすることを覚えておいてください。
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
- このプロジェクトをサポートしたい場合, Gittip Flattr のページを見てください。
1231
+ このプロジェクトをサポートしたい場合, GitHub sponsors のページを見てください。
1232
1232
 
1233
- [![Gittip donate button](http://img.shields.io/gittip/bevry.png)](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")
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) [![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
- [![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")
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: <http://slim-lang.com>
32
- * Source: <http://github.com/slim-template/slim>
33
- * Bugs: <http://github.com/slim-template/slim/issues>
34
- * List: <http://groups.google.com/group/slim-template>
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: <http://rubydoc.info/gems/slim/frames> <https://www.omniref.com/ruby/gems/slim>
37
- * GitHub master: <http://rubydoc.info/github/slim-template/slim/master/frames> <https://www.omniref.com/github/slim-template/slim>
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 3 and later__. It has been heavily tested on all major ruby implementations. We use
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="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
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="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
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="http://slim-lang.com/" Slim-lang.com
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="http://slim-lang.com/">Slim-lang.com</a>
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: 'http://slim-lang.com/'}
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="http://slim-lang.com/">Link</a>
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 = { 'http://slim-lang.com' => 'The Slim Template Language' }
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&lt;String&gt; | :hyphen_attrs | %w(data) | Attributes which will be hyphenated if a Hash is given (e.g. data={a:1,b:2} will render as data-a="1" data-b="2") |
1014
+ | Array&lt;String&gt; | :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.0, 2.1, 2.2 and 2.3
1202
- * JRuby 1.9 mode
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.0.0, 2.1.0, 2.2.0 and 2.3.0.
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 Gittip and Flattr pages.
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
- Currently the donations will be used to cover the hosting costs (domain name etc).
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
- * [Jade (Similar engine for javascript)](https://github.com/visionmedia/jade)
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
- desc 'Run Slim benchmarks! (default parameters slow=false)'
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
@@ -13,7 +13,7 @@ Gettext は文字列を英語からドイツ語に変換し, 文字列が展開
13
13
 
14
14
  次のようにレンダリングされます。
15
15
 
16
- <h1>Willkommen auf slim-lang.com!</h1>
16
+ <h1>Willkommen auf github.com/slim-template/slim!</h1>
17
17
 
18
18
  翻訳プラグインを有効化します。
19
19
 
data/doc/logic_less.md CHANGED
@@ -80,7 +80,7 @@ This will yield
80
80
 
81
81
  <tr>
82
82
  <td>Article 1</td>
83
- </>
83
+ </tr>
84
84
  <tr>
85
85
  <td>Article 2</td>
86
86
  </tr>
data/doc/translator.md CHANGED
@@ -13,7 +13,7 @@ Gettext translates the string from english to german where interpolations are re
13
13
 
14
14
  and renders as
15
15
 
16
- <h1>Willkommen auf slim-lang.com!</h1>
16
+ <h1>Willkommen auf github.com/slim-template/slim!</h1>
17
17
 
18
18
  Enable the translator plugin with
19
19
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Slim
2
3
  # @api private
3
4
  class CodeAttributes < Filter
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Slim
2
3
  # @api private
3
4
  class Controls < Filter