slim 5.2.1 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +57 -12
- data/CHANGES +8 -2
- data/Gemfile +5 -2
- data/LICENSE +1 -1
- data/README.jp.md +10 -12
- data/README.md +21 -26
- data/lib/slim/embedded.rb +1 -1
- data/lib/slim/logic_less/context.rb +4 -3
- data/lib/slim/splat/builder.rb +18 -19
- data/lib/slim/version.rb +1 -1
- data/test/core/test_embedded_engines.rb +16 -0
- data/test/logic_less/test_logic_less.rb +11 -0
- data/test/rails/config/application.rb +1 -0
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 736f672a47e9e8c955c9ff289e7937a69f9409a1d6bb5bfb887e5c995b565abc
|
|
4
|
+
data.tar.gz: 815a6e60f87e6864bf3ca7ffb39bce77625a96c56d2cd8189a180dd421cd9db6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f83ed71a63515c0d490dd99064c74e7b164351a0c62f78dc0c3600c3a4357fb5669e0e68a4193fdc014a909824f1f8c17d3e42f1ad71f157d70b30ffd8dd3983
|
|
7
|
+
data.tar.gz: 7cb655a1425fb047256ec8d21bdefcddd02cc38cce40489c4e05ac101e5799b8d711076434429c03dad3eaec8ca71f7d8abfd57f461b039007a320b2900b1b51
|
data/.github/workflows/test.yml
CHANGED
|
@@ -7,21 +7,26 @@ on:
|
|
|
7
7
|
paths-ignore:
|
|
8
8
|
- '**.md'
|
|
9
9
|
schedule:
|
|
10
|
-
- cron: "
|
|
10
|
+
- cron: "6 8 * * 0"
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
11
13
|
jobs:
|
|
12
14
|
basic:
|
|
13
15
|
runs-on: ubuntu-latest
|
|
14
16
|
strategy:
|
|
15
17
|
fail-fast: false
|
|
16
18
|
matrix:
|
|
17
|
-
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
|
|
19
|
+
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
|
|
18
20
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
21
|
+
- uses: actions/checkout@v6
|
|
22
|
+
with:
|
|
23
|
+
persist-credentials: false
|
|
20
24
|
- name: Set up Ruby
|
|
21
25
|
uses: ruby/setup-ruby@v1
|
|
22
26
|
with:
|
|
23
27
|
ruby-version: ${{ matrix.ruby }}
|
|
24
28
|
- run: bundle update && bundle exec rake test
|
|
29
|
+
name: "rake test"
|
|
25
30
|
- run: bundle update && bundle exec rake test:sinatra
|
|
26
31
|
name: "rake test:sinatra SINATRA=2.2.4"
|
|
27
32
|
env:
|
|
@@ -42,10 +47,20 @@ jobs:
|
|
|
42
47
|
env:
|
|
43
48
|
SINATRA: 3.2.0
|
|
44
49
|
- run: bundle update && bundle exec rake test:sinatra
|
|
45
|
-
name: "rake test:sinatra SINATRA=4.0.
|
|
50
|
+
name: "rake test:sinatra SINATRA=4.0.1"
|
|
51
|
+
if: ${{ matrix.ruby != '2.5' && matrix.ruby != '2.6' }}
|
|
52
|
+
env:
|
|
53
|
+
SINATRA: 4.0.1
|
|
54
|
+
- run: bundle update && bundle exec rake test:sinatra
|
|
55
|
+
name: "rake test:sinatra SINATRA=4.1.1"
|
|
56
|
+
if: ${{ matrix.ruby != '2.5' && matrix.ruby != '2.6' }}
|
|
57
|
+
env:
|
|
58
|
+
SINATRA: 4.1.1
|
|
59
|
+
- run: bundle update && bundle exec rake test:sinatra
|
|
60
|
+
name: "rake test:sinatra SINATRA=4.2.1"
|
|
46
61
|
if: ${{ matrix.ruby != '2.5' && matrix.ruby != '2.6' }}
|
|
47
62
|
env:
|
|
48
|
-
SINATRA: 4.
|
|
63
|
+
SINATRA: 4.2.1
|
|
49
64
|
- run: bundle update && bundle exec rake test:sinatra
|
|
50
65
|
name: "rake test:sinatra SINATRA=main"
|
|
51
66
|
if: ${{ matrix.ruby != '2.5' && matrix.ruby != '2.6' }}
|
|
@@ -56,7 +71,9 @@ jobs:
|
|
|
56
71
|
strategy:
|
|
57
72
|
fail-fast: false
|
|
58
73
|
steps:
|
|
59
|
-
- uses: actions/checkout@
|
|
74
|
+
- uses: actions/checkout@v6
|
|
75
|
+
with:
|
|
76
|
+
persist-credentials: false
|
|
60
77
|
- name: Set up Ruby
|
|
61
78
|
uses: ruby/setup-ruby@v1
|
|
62
79
|
with:
|
|
@@ -70,7 +87,9 @@ jobs:
|
|
|
70
87
|
strategy:
|
|
71
88
|
fail-fast: false
|
|
72
89
|
steps:
|
|
73
|
-
- uses: actions/checkout@
|
|
90
|
+
- uses: actions/checkout@v6
|
|
91
|
+
with:
|
|
92
|
+
persist-credentials: false
|
|
74
93
|
- name: Set up Ruby
|
|
75
94
|
uses: ruby/setup-ruby@v1
|
|
76
95
|
with:
|
|
@@ -88,19 +107,45 @@ jobs:
|
|
|
88
107
|
strategy:
|
|
89
108
|
fail-fast: false
|
|
90
109
|
steps:
|
|
91
|
-
- uses: actions/checkout@
|
|
110
|
+
- uses: actions/checkout@v6
|
|
111
|
+
with:
|
|
112
|
+
persist-credentials: false
|
|
92
113
|
- name: Set up Ruby
|
|
93
114
|
uses: ruby/setup-ruby@v1
|
|
94
115
|
with:
|
|
95
116
|
ruby-version: 3.3
|
|
96
117
|
- run: bundle update && bundle exec rake test:rails
|
|
97
|
-
name: "rake test:rails RAILS=7.0.
|
|
118
|
+
name: "rake test:rails RAILS=7.0.10"
|
|
119
|
+
env:
|
|
120
|
+
RAILS: 7.0.10
|
|
121
|
+
- run: bundle update && bundle exec rake test:rails
|
|
122
|
+
name: "rake test:rails RAILS=7.1.6"
|
|
123
|
+
env:
|
|
124
|
+
RAILS: 7.1.6
|
|
125
|
+
- run: bundle update && bundle exec rake test:rails
|
|
126
|
+
name: "rake test:rails RAILS=7.2.3"
|
|
127
|
+
env:
|
|
128
|
+
RAILS: 7.2.3
|
|
129
|
+
rails-8:
|
|
130
|
+
runs-on: ubuntu-latest
|
|
131
|
+
strategy:
|
|
132
|
+
fail-fast: false
|
|
133
|
+
steps:
|
|
134
|
+
- uses: actions/checkout@v6
|
|
135
|
+
with:
|
|
136
|
+
persist-credentials: false
|
|
137
|
+
- name: Set up Ruby
|
|
138
|
+
uses: ruby/setup-ruby@v1
|
|
139
|
+
with:
|
|
140
|
+
ruby-version: 3.4
|
|
141
|
+
- run: bundle update && bundle exec rake test:rails
|
|
142
|
+
name: "rake test:rails RAILS=8.0.4"
|
|
98
143
|
env:
|
|
99
|
-
RAILS:
|
|
144
|
+
RAILS: 8.0.5
|
|
100
145
|
- run: bundle update && bundle exec rake test:rails
|
|
101
|
-
name: "rake test:rails RAILS=
|
|
146
|
+
name: "rake test:rails RAILS=8.1.1"
|
|
102
147
|
env:
|
|
103
|
-
RAILS:
|
|
148
|
+
RAILS: 8.1.3
|
|
104
149
|
- run: bundle update && bundle exec rake test:rails
|
|
105
150
|
name: "rake test:rails RAILS=main"
|
|
106
151
|
env:
|
data/CHANGES
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
5.2.2 (2026-07-24)
|
|
2
|
+
|
|
3
|
+
* Remove legacy less engine - #963
|
|
4
|
+
* Add asciidoc engine - #973
|
|
5
|
+
* Fix logic less condition for empty objects - #970
|
|
6
|
+
|
|
1
7
|
5.2.1 (2024-01-20)
|
|
2
8
|
|
|
3
9
|
* Support Ruby 3.3
|
|
@@ -33,11 +39,11 @@
|
|
|
33
39
|
* Remove deprecated syntax
|
|
34
40
|
* Add option to hyphenate underscore attributes - #852
|
|
35
41
|
* Update CI/CD testing and dependencies
|
|
36
|
-
|
|
42
|
+
|
|
37
43
|
4.1.0 (2020-05-07)
|
|
38
44
|
* Add support for Tailwind CSS - #841
|
|
39
45
|
* Update dependencies and testing
|
|
40
|
-
|
|
46
|
+
|
|
41
47
|
4.0.1 (2018-09-02)
|
|
42
48
|
|
|
43
49
|
* Fix incompatibility issue with Slim Include plugin and new ability to specifiy attributes for embedded engines #819
|
data/Gemfile
CHANGED
|
@@ -2,9 +2,12 @@ source 'https://rubygems.org/'
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
+
gem 'logger', '~> 1.7'
|
|
6
|
+
gem 'ostruct', '~> 0.6'
|
|
5
7
|
gem 'minitest', '~> 5.15'
|
|
6
|
-
gem 'rake', '~> 13.
|
|
7
|
-
gem '
|
|
8
|
+
gem 'rake', '~> 13.3'
|
|
9
|
+
gem 'asciidoctor', '~> 2.0'
|
|
10
|
+
gem 'kramdown', '~> 2.5'
|
|
8
11
|
|
|
9
12
|
if ENV['TEMPLE'] && ENV['TEMPLE'] != 'master'
|
|
10
13
|
gem 'temple', "= #{ENV['TEMPLE']}"
|
data/LICENSE
CHANGED
data/README.jp.md
CHANGED
|
@@ -566,7 +566,7 @@ div class="first second third"
|
|
|
566
566
|
|
|
567
567
|
~~~ slim
|
|
568
568
|
ruby:
|
|
569
|
-
def a_unless_current
|
|
569
|
+
def self.a_unless_current
|
|
570
570
|
@page_current ? {tag: 'span'} : {tag: 'a', href: 'https://slim-template.github.io/'}
|
|
571
571
|
end
|
|
572
572
|
- @page_current = true
|
|
@@ -866,8 +866,8 @@ p: markdown: Tag with **inline** markdown!
|
|
|
866
866
|
| css: | なし | ショートカット | css コードを埋め込み、style タグで囲む |
|
|
867
867
|
| sass: | sass-embedded または sassc または sass | コンパイル時 | sass コードを埋め込み、style タグで囲む |
|
|
868
868
|
| scss: | sass-embedded または sassc または sass | コンパイル時 | scss コードを埋め込み、style タグで囲む |
|
|
869
|
-
| less: | less | コンパイル時 | less コードを埋め込み、style タグで囲む |
|
|
870
869
|
| coffee: | coffee-script | コンパイル時 | CoffeeScript をコンパイルし、 script タグで囲む |
|
|
870
|
+
| asciidoc: | asciidoctor | コンパイル時 + 展開 | AsciiDoc をコンパイルし、テキスト中の # \{variables} を展開 |
|
|
871
871
|
| markdown: | redcarpet/rdiscount/kramdown | コンパイル時 + 展開 | Markdown をコンパイルし、テキスト中の # \{variables} を展開 |
|
|
872
872
|
| textile: | redcloth | コンパイル時 + 展開 | textile をコンパイルし、テキスト中の # \{variables} を展開 |
|
|
873
873
|
| rdoc: | rdoc | コンパイル時 + 展開 | RDoc をコンパイルし、テキスト中の # \{variables} を展開 |
|
|
@@ -883,7 +883,6 @@ Slim::Embedded.options[:markdown] = {auto_ids: false}
|
|
|
883
883
|
* Javascript
|
|
884
884
|
* CSS
|
|
885
885
|
* CoffeeScript
|
|
886
|
-
* LESS
|
|
887
886
|
* SASS
|
|
888
887
|
* SCSS
|
|
889
888
|
|
|
@@ -1160,7 +1159,6 @@ markdown:
|
|
|
1160
1159
|
* [Textmate / Sublime Text](https://github.com/slim-template/ruby-slim.tmbundle)
|
|
1161
1160
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
|
1162
1161
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
|
1163
|
-
* [Atom](https://github.com/slim-template/language-slim)
|
|
1164
1162
|
|
|
1165
1163
|
### テンプレート変換 (HAML, ERB, ...)
|
|
1166
1164
|
|
|
@@ -1244,7 +1242,6 @@ Slim は [MIT license](http://www.opensource.org/licenses/MIT) に基づいて
|
|
|
1244
1242
|
* [Textmate / Sublime Text](https://github.com/slim-template/ruby-slim.tmbundle)
|
|
1245
1243
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
|
1246
1244
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
|
1247
|
-
* [Atom](https://github.com/slim-template/language-slim)
|
|
1248
1245
|
|
|
1249
1246
|
静的コード解析:
|
|
1250
1247
|
|
|
@@ -1259,18 +1256,19 @@ Slim は [MIT license](http://www.opensource.org/licenses/MIT) に基づいて
|
|
|
1259
1256
|
移植言語/同様の言語:
|
|
1260
1257
|
|
|
1261
1258
|
* [Sliq (Slim/Liquid integration)](https://github.com/slim-template/sliq)
|
|
1262
|
-
* [Slm (Slim port to Javascript)](https://github.com/slm-lang/slm)
|
|
1263
|
-
* [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
|
|
1264
|
-
* [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
|
|
1265
1259
|
* [Hamlet.rb (Similar template language)](https://github.com/gregwebs/hamlet.rb)
|
|
1266
|
-
* [
|
|
1260
|
+
* [Slm (Slim port to Javascript)](https://github.com/slm-lang/slm)
|
|
1267
1261
|
* [Skim (Slim for Javascript)](https://github.com/jfirebaugh/skim)
|
|
1268
1262
|
* [Emblem.js (Javascript, similar to Slim)](https://github.com/machty/emblem.js)
|
|
1269
|
-
* [Hamlit (High performance Haml implementation, based on Temple like Slim)](https://github.com/k0kubun/hamlit)
|
|
1270
|
-
* [Faml (Faster Haml implementation, also using Temple like Slim)](https://github.com/eagletmt/faml)
|
|
1271
|
-
* [Haml (Older engine which inspired Slim)](https://github.com/haml/haml)
|
|
1272
1263
|
* [Jade (Similar engine for javascript)](https://github.com/visionmedia/jade)
|
|
1273
1264
|
* [Pug (Successor of Jade, Similar engine for javascript)](https://github.com/pugjs/pug)
|
|
1265
|
+
* [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
|
|
1266
|
+
* [Plim (Python port of Slim)](https://github.com/2nd/plim)
|
|
1267
|
+
* [Trim-Template (Python template engine inspired by Slim)](https://github.com/opensourceame/trim-template)
|
|
1268
|
+
* [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
|
|
1269
|
+
* [Hamlit (Haml implementation, using Temple like Slim)](https://github.com/k0kubun/hamlit)
|
|
1270
|
+
* [Faml (Haml implementation, using Temple like Slim)](https://github.com/eagletmt/faml)
|
|
1271
|
+
* [Haml (Older template engine which inspired Slim)](https://github.com/haml/haml)
|
|
1274
1272
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
|
1275
1273
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
|
1276
1274
|
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/README.md
CHANGED
|
@@ -41,7 +41,7 @@ A short list of the features...
|
|
|
41
41
|
### What is Slim?
|
|
42
42
|
|
|
43
43
|
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
|
-
continuous integration (
|
|
44
|
+
continuous integration (GitHub actions).
|
|
45
45
|
|
|
46
46
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
|
47
47
|
|
|
@@ -502,7 +502,7 @@ You can also break ruby attributes with backslash `\` or trailing `,` as describ
|
|
|
502
502
|
#### Boolean attributes
|
|
503
503
|
|
|
504
504
|
The attribute values `true`, `false` and `nil` are interpreted
|
|
505
|
-
as booleans. If you use the attribute wrapper you can omit the attribute
|
|
505
|
+
as booleans. If you use the attribute wrapper you can omit the attribute assignment.
|
|
506
506
|
|
|
507
507
|
~~~ slim
|
|
508
508
|
input type="text" disabled="disabled"
|
|
@@ -578,7 +578,7 @@ with the :tag key.
|
|
|
578
578
|
|
|
579
579
|
~~~ slim
|
|
580
580
|
ruby:
|
|
581
|
-
def a_unless_current
|
|
581
|
+
def self.a_unless_current
|
|
582
582
|
@page_current ? {tag: 'span'} : {tag: 'a', href: 'https://slim-template.github.io/'}
|
|
583
583
|
end
|
|
584
584
|
- @page_current = true
|
|
@@ -696,7 +696,7 @@ which renders to
|
|
|
696
696
|
~~~ html
|
|
697
697
|
<script data-binding="products" type="text/javascript">
|
|
698
698
|
[{"name": "product1", "price": "$100"},
|
|
699
|
-
{"name": "
|
|
699
|
+
{"name": "product2", "price": "$200"}]
|
|
700
700
|
</script>
|
|
701
701
|
~~~
|
|
702
702
|
|
|
@@ -902,8 +902,8 @@ Supported engines:
|
|
|
902
902
|
| css: | none | Shortcut | Shortcut to embed css code and wrap in style tag |
|
|
903
903
|
| sass: | sass-embedded or sassc or sass | Compile time | Embed sass code and wrap in style tag |
|
|
904
904
|
| scss: | sass-embedded or sassc or sass | Compile time | Embed scss code and wrap in style tag |
|
|
905
|
-
| less: | less | Compile time | Embed less css code and wrap in style tag |
|
|
906
905
|
| coffee: | coffee-script | Compile time | Compile coffee script code and wrap in script tag |
|
|
906
|
+
| asciidoc: | asciidoctor | Compile time + Interpolation | Compile AsciiDoc code and interpolate #\{variables} in text |
|
|
907
907
|
| markdown: | redcarpet/rdiscount/kramdown | Compile time + Interpolation | Compile markdown code and interpolate #\{variables} in text |
|
|
908
908
|
| textile: | redcloth | Compile time + Interpolation | Compile textile code and interpolate #\{variables} in text |
|
|
909
909
|
| rdoc: | rdoc | Compile time + Interpolation | Compile rdoc code and interpolate #\{variables} in text |
|
|
@@ -918,7 +918,6 @@ You can also specify HTML attributes for the following embedded engines:
|
|
|
918
918
|
* Javascript
|
|
919
919
|
* CSS
|
|
920
920
|
* CoffeeScript
|
|
921
|
-
* LESS
|
|
922
921
|
* SASS
|
|
923
922
|
* SCSS
|
|
924
923
|
|
|
@@ -1114,11 +1113,11 @@ There are two ways to resolve it:
|
|
|
1114
1113
|
* Set `splat_prefix` to any custom value, double asterisk, for example: `splat_prefix: '**'`. Now structural directives should work as expected. Remember that now splat attributes should be written with new custom prefix before them.
|
|
1115
1114
|
* Use alternative directive syntax without asterisk.
|
|
1116
1115
|
|
|
1117
|
-
#### Attribute
|
|
1116
|
+
#### Attribute delimiters
|
|
1118
1117
|
|
|
1119
1118
|
Angular and slim both uses brackets in their syntax. So there are also two ways:
|
|
1120
1119
|
* Use alternative syntax for binding (`bind-...` and so on)
|
|
1121
|
-
* Limit attribute
|
|
1120
|
+
* Limit attribute delimiters to curly braces only:
|
|
1122
1121
|
```
|
|
1123
1122
|
code_attr_delims: {
|
|
1124
1123
|
'{' => '}',
|
|
@@ -1196,12 +1195,11 @@ There are plugins for various text editors (including the most important ones -
|
|
|
1196
1195
|
* [Textmate / Sublime Text](https://github.com/slim-template/ruby-slim.tmbundle)
|
|
1197
1196
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
|
1198
1197
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
|
1199
|
-
* [Atom](https://github.com/slim-template/language-slim)
|
|
1200
1198
|
* VS Code ([Official marketplace](https://marketplace.visualstudio.com/items?itemName=sianglim.slim), [Open VSX registry](https://open-vsx.org/extension/sianglim/slim))
|
|
1201
1199
|
|
|
1202
1200
|
### Template Converters (HAML, ERB, ...)
|
|
1203
1201
|
|
|
1204
|
-
* Slim can be converted to ERB using `slimrb` or `Slim::ERBConverter
|
|
1202
|
+
* Slim can be converted to ERB using `slimrb` or `Slim::ERBConverter` which are both included in the Slim gem
|
|
1205
1203
|
* [Haml2Slim converter](https://github.com/slim-template/haml2slim)
|
|
1206
1204
|
* [ERB2Slim, HTML2Slim converter](https://github.com/slim-template/html2slim)
|
|
1207
1205
|
|
|
@@ -1214,12 +1212,7 @@ There are plugins for various text editors (including the most important ones -
|
|
|
1214
1212
|
But we would be happy if you chose Slim also for any other reason, we assure
|
|
1215
1213
|
you performance will not be an obstacle.*
|
|
1216
1214
|
|
|
1217
|
-
|
|
1218
|
-
run the slow parsing benchmark which needs more time. You can also increase the number of iterations.
|
|
1219
|
-
|
|
1220
|
-
~~~
|
|
1221
|
-
$ rake bench slow=1 iterations=1000
|
|
1222
|
-
~~~
|
|
1215
|
+
For up-to-date benchmarks, please refer to our dedicated [Template engine benchmarks](https://github.com/slim-template/benchmarks) repository.
|
|
1223
1216
|
|
|
1224
1217
|
### Test suite and continuous integration
|
|
1225
1218
|
|
|
@@ -1259,7 +1252,8 @@ Slim is released under the [MIT license](http://www.opensource.org/licenses/MIT)
|
|
|
1259
1252
|
|
|
1260
1253
|
## Donations and sponsoring
|
|
1261
1254
|
|
|
1262
|
-
|
|
1255
|
+
This project relies on sponsoring for its continued maintenance. If you want to
|
|
1256
|
+
support the project, please visit the GitHub sponsors page.
|
|
1263
1257
|
|
|
1264
1258
|
[](https://github.com/sponsors/slim-template)
|
|
1265
1259
|
|
|
@@ -1281,7 +1275,6 @@ Syntax highlighting:
|
|
|
1281
1275
|
* [Textmate / Sublime Text](https://github.com/slim-template/ruby-slim.tmbundle)
|
|
1282
1276
|
* [Espresso text editor](https://github.com/slim-template/Slim-Sugar)
|
|
1283
1277
|
* [Coda](https://github.com/slim-template/Coda-2-Slim.mode)
|
|
1284
|
-
* [Atom](https://github.com/slim-template/language-slim)
|
|
1285
1278
|
|
|
1286
1279
|
Static code analysis:
|
|
1287
1280
|
|
|
@@ -1297,17 +1290,19 @@ Template Converters (HAML, ERB, ...):
|
|
|
1297
1290
|
Language ports/Similar languages:
|
|
1298
1291
|
|
|
1299
1292
|
* [Sliq (Slim/Liquid integration)](https://github.com/slim-template/sliq)
|
|
1300
|
-
* [Slm (Slim port to Javascript)](https://github.com/slm-lang/slm)
|
|
1301
|
-
* [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
|
|
1302
|
-
* [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
|
|
1303
1293
|
* [Hamlet.rb (Similar template language)](https://github.com/gregwebs/hamlet.rb)
|
|
1304
|
-
* [
|
|
1294
|
+
* [Slm (Slim port to Javascript)](https://github.com/slm-lang/slm)
|
|
1305
1295
|
* [Skim (Slim for Javascript)](https://github.com/jfirebaugh/skim)
|
|
1306
1296
|
* [Emblem.js (Javascript, similar to Slim)](https://github.com/machty/emblem.js)
|
|
1307
|
-
* [
|
|
1308
|
-
* [
|
|
1309
|
-
* [
|
|
1310
|
-
* [
|
|
1297
|
+
* [Jade (Similar engine for javascript)](https://github.com/visionmedia/jade)
|
|
1298
|
+
* [Pug (Successor of Jade, Similar engine for javascript)](https://github.com/pugjs/pug)
|
|
1299
|
+
* [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
|
|
1300
|
+
* [Plim (Python port of Slim)](https://github.com/2nd/plim)
|
|
1301
|
+
* [Trim-Template (Python template engine inspired by Slim)](https://github.com/opensourceame/trim-template)
|
|
1302
|
+
* [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
|
|
1303
|
+
* [Hamlit (Haml implementation, using Temple like Slim)](https://github.com/k0kubun/hamlit)
|
|
1304
|
+
* [Faml (Haml implementation, using Temple like Slim)](https://github.com/eagletmt/faml)
|
|
1305
|
+
* [Haml (Older template engine which inspired Slim)](https://github.com/haml/haml)
|
|
1311
1306
|
* [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
|
|
1312
1307
|
* [Amber (Similar engine for Go)](https://github.com/eknkc/amber)
|
|
1313
1308
|
* [Slang (Slim-inspired templating language for Crystal)](https://github.com/jeromegn/slang)
|
data/lib/slim/embedded.rb
CHANGED
|
@@ -228,13 +228,13 @@ module Slim
|
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
# These engines are executed at compile time, embedded ruby is interpolated
|
|
231
|
+
register :asciidoc, InterpolateTiltEngine
|
|
231
232
|
register :markdown, InterpolateTiltEngine
|
|
232
233
|
register :textile, InterpolateTiltEngine
|
|
233
234
|
register :rdoc, InterpolateTiltEngine
|
|
234
235
|
|
|
235
236
|
# These engines are executed at compile time
|
|
236
237
|
register :coffee, JavaScriptEngine, engine: TiltEngine
|
|
237
|
-
register :less, TagEngine, tag: :style, engine: TiltEngine
|
|
238
238
|
register :sass, TagEngine, :pretty, tag: :style, engine: SassEngine
|
|
239
239
|
register :scss, TagEngine, :pretty, tag: :style, engine: SassEngine
|
|
240
240
|
|
|
@@ -27,7 +27,8 @@ module Slim
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def section(name)
|
|
30
|
-
|
|
30
|
+
dict = scope[name]
|
|
31
|
+
if dict && !(dict.respond_to?(:empty?) && dict.empty?)
|
|
31
32
|
if !dict.respond_to?(:has_key?) && dict.respond_to?(:each)
|
|
32
33
|
new_scope do
|
|
33
34
|
dict.each do |d|
|
|
@@ -42,8 +43,8 @@ module Slim
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def inverted_section(name)
|
|
45
|
-
|
|
46
|
-
yield if !
|
|
46
|
+
dict = scope[name]
|
|
47
|
+
yield if !dict || (dict.respond_to?(:empty?) && dict.empty?)
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def to_s
|
data/lib/slim/splat/builder.rb
CHANGED
|
@@ -48,25 +48,7 @@ module Slim
|
|
|
48
48
|
tag = @attrs.delete('tag').to_s
|
|
49
49
|
tag = @options[:default_tag] if tag.empty?
|
|
50
50
|
if block
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
# TODO: Add this as a helper somewhere to solve these capturing issues
|
|
54
|
-
# once and for all.
|
|
55
|
-
#
|
|
56
|
-
# If we have Slim capturing disabled and the scope defines the method `capture` (i.e. Rails)
|
|
57
|
-
# we use this method to capture the content.
|
|
58
|
-
#
|
|
59
|
-
# otherwise we just use normal Slim capturing (yield).
|
|
60
|
-
#
|
|
61
|
-
# See https://github.com/slim-template/slim/issues/591
|
|
62
|
-
# https://github.com/slim-template/slim#helpers-capturing-and-includes
|
|
63
|
-
#
|
|
64
|
-
content =
|
|
65
|
-
if @options[:disable_capture] && (scope = block.binding.eval('self')).respond_to?(:capture)
|
|
66
|
-
scope.capture(&block)
|
|
67
|
-
else
|
|
68
|
-
yield
|
|
69
|
-
end
|
|
51
|
+
content = capture_block_content(&block)
|
|
70
52
|
"<#{tag}#{build_attrs}>#{content}</#{tag}>"
|
|
71
53
|
else
|
|
72
54
|
"<#{tag}#{build_attrs} />"
|
|
@@ -90,6 +72,23 @@ module Slim
|
|
|
90
72
|
|
|
91
73
|
private
|
|
92
74
|
|
|
75
|
+
# Captures block content using the appropriate capturing mechanism.
|
|
76
|
+
#
|
|
77
|
+
# If we have Slim capturing disabled and the scope defines the method `capture` (i.e. Rails)
|
|
78
|
+
# we use this method to capture the content.
|
|
79
|
+
#
|
|
80
|
+
# Otherwise we just use normal Slim capturing (yield).
|
|
81
|
+
#
|
|
82
|
+
# See https://github.com/slim-template/slim/issues/591
|
|
83
|
+
# https://github.com/slim-template/slim#helpers-capturing-and-includes
|
|
84
|
+
def capture_block_content(&block)
|
|
85
|
+
if @options[:disable_capture] && (scope = block.binding.eval('self')).respond_to?(:capture)
|
|
86
|
+
scope.capture(&block)
|
|
87
|
+
else
|
|
88
|
+
yield
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
93
92
|
def hyphen_attr(name, escape, value)
|
|
94
93
|
if Hash === value
|
|
95
94
|
if @options[:hyphen_underscore_attrs]
|
data/lib/slim/version.rb
CHANGED
|
@@ -3,6 +3,22 @@ require 'erb'
|
|
|
3
3
|
|
|
4
4
|
class TestSlimEmbeddedEngines < TestSlim
|
|
5
5
|
|
|
6
|
+
def test_wip_render_with_asciidoc
|
|
7
|
+
source = %q{
|
|
8
|
+
asciidoc:
|
|
9
|
+
== Header
|
|
10
|
+
Hello from #{"AsciiDoc!"}
|
|
11
|
+
|
|
12
|
+
#{1+2}
|
|
13
|
+
|
|
14
|
+
* one
|
|
15
|
+
* two
|
|
16
|
+
}
|
|
17
|
+
output = render(source)
|
|
18
|
+
assert_match 'sect1', output
|
|
19
|
+
assert_match 'Hello from AsciiDoc!', output
|
|
20
|
+
end
|
|
21
|
+
|
|
6
22
|
def test_render_with_markdown
|
|
7
23
|
source = %q{
|
|
8
24
|
markdown:
|
|
@@ -302,6 +302,17 @@ a href=output_number Link
|
|
|
302
302
|
assert_html'<li class="previous"><a href="prev">Older</a></li><li class="next"><a href="next">Newer</a></li>', source, scope: {prev_page: 'prev', next_page: 'next'}
|
|
303
303
|
end
|
|
304
304
|
|
|
305
|
+
def test_empty_conditional
|
|
306
|
+
source = %q{
|
|
307
|
+
- prev_page
|
|
308
|
+
li.previous
|
|
309
|
+
a href=prev_page Older
|
|
310
|
+
- next_page
|
|
311
|
+
li.next
|
|
312
|
+
a href=next_page Newer}
|
|
313
|
+
assert_html'<li class="next"><a href="next">Newer</a></li>', source, scope: {prev_page: '', next_page: 'next'}
|
|
314
|
+
end
|
|
315
|
+
|
|
305
316
|
def test_render_with_yield
|
|
306
317
|
source = %q{
|
|
307
318
|
div
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.2.
|
|
4
|
+
version: 5.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Mendler
|
|
8
8
|
- Andrew Stone
|
|
9
9
|
- Fred Wu
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 2026-07-24 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: temple
|
|
@@ -189,7 +188,6 @@ metadata:
|
|
|
189
188
|
source_code_uri: https://github.com/slim-template/slim
|
|
190
189
|
wiki_uri: https://github.com/slim-template/slim/wiki
|
|
191
190
|
funding_uri: https://github.com/sponsors/slim-template
|
|
192
|
-
post_install_message:
|
|
193
191
|
rdoc_options: []
|
|
194
192
|
require_paths:
|
|
195
193
|
- lib
|
|
@@ -204,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
204
202
|
- !ruby/object:Gem::Version
|
|
205
203
|
version: '0'
|
|
206
204
|
requirements: []
|
|
207
|
-
rubygems_version: 3.
|
|
208
|
-
signing_key:
|
|
205
|
+
rubygems_version: 3.6.7
|
|
209
206
|
specification_version: 4
|
|
210
207
|
summary: Slim is a template language.
|
|
211
208
|
test_files: []
|