slim 1.3.6 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +17 -5
- data/CHANGES +32 -0
- data/Gemfile +9 -1
- data/README.md +51 -32
- data/lib/slim.rb +2 -2
- data/lib/slim/code_attributes.rb +3 -3
- data/lib/slim/command.rb +4 -7
- data/lib/slim/{control_structures.rb → controls.rb} +1 -1
- data/lib/slim/{embedded_engine.rb → embedded.rb} +23 -4
- data/lib/slim/end_inserter.rb +1 -1
- data/lib/slim/engine.rb +28 -13
- data/lib/slim/filter.rb +1 -1
- data/lib/slim/logic_less/filter.rb +1 -1
- data/lib/slim/parser.rb +49 -22
- data/lib/slim/splat_attributes.rb +7 -7
- data/lib/slim/template.rb +2 -2
- data/lib/slim/translator.rb +3 -3
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -8
- data/test/core/helper.rb +21 -13
- data/test/core/test_code_escaping.rb +62 -4
- data/test/core/test_code_structure.rb +42 -0
- data/test/core/test_embedded_engines.rb +79 -0
- data/test/core/test_html_attributes.rb +23 -1
- data/test/core/test_parser_errors.rb +8 -0
- data/test/core/test_pretty.rb +37 -8
- data/test/core/test_ruby_errors.rb +6 -2
- data/test/core/test_tabs.rb +169 -0
- data/test/literate/TESTS.md +26 -6
- data/test/rails/app/controllers/parents_controller.rb +1 -0
- data/test/rails/app/controllers/slim_controller.rb +1 -1
- data/test/rails/config/environments/test.rb +2 -0
- data/test/rails/config/initializers/secret_token.rb +1 -1
- data/test/rails/test/test_slim.rb +6 -2
- metadata +12 -115
- data/test/rails/config/environments/development.rb +0 -23
- data/test/rails/config/environments/production.rb +0 -49
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 46f376c5e0b3f395ccf918b89355717d62d28c0e
|
4
|
+
data.tar.gz: 5b1f71d32c229146001bdffa4f3b693b6333e512
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a4816cbd0490de7df3248cb095c09f3306b509fe9295b7f8d5a702a2fe8ef37b3b727770c94b4dd5e4318c9b55e8300511fafba5a92202c2fb7f7be5961f521
|
7
|
+
data.tar.gz: 60f673c3b31c65d19c6098145889f100e597d51ccd05b500d0e656e14583b601f05bb3d115c1a23053a268c9f3013e01c8131b0d38d05d4fe5baf647c0f97371
|
data/.travis.yml
CHANGED
@@ -2,6 +2,7 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 1.8.7
|
4
4
|
- 1.9.3
|
5
|
+
- 2.0.0
|
5
6
|
- ruby-head
|
6
7
|
- jruby-18mode
|
7
8
|
- jruby-19mode
|
@@ -10,11 +11,13 @@ rvm:
|
|
10
11
|
env:
|
11
12
|
- "TASK=test:core_and_plugins"
|
12
13
|
- "TASK=test:rails RAILS=master"
|
13
|
-
- "TASK=test:rails RAILS=3.0.
|
14
|
-
- "TASK=test:rails RAILS=3.1.
|
15
|
-
- "TASK=test:rails RAILS=3.2.
|
14
|
+
- "TASK=test:rails RAILS=3.0.20"
|
15
|
+
- "TASK=test:rails RAILS=3.1.12"
|
16
|
+
- "TASK=test:rails RAILS=3.2.13"
|
17
|
+
- "TASK=test:rails RAILS=4.0.0.beta1"
|
16
18
|
- "TASK=test:sinatra SINATRA=master"
|
17
|
-
- "TASK=test:sinatra SINATRA=1.3.
|
19
|
+
- "TASK=test:sinatra SINATRA=1.3.6"
|
20
|
+
- "TASK=test:sinatra SINATRA=1.4.2"
|
18
21
|
- "TASK=bench iterations=10000"
|
19
22
|
- "TASK=bench slow=1 iterations=1000"
|
20
23
|
matrix:
|
@@ -26,12 +29,21 @@ matrix:
|
|
26
29
|
env: "TASK=test:rails RAILS=master"
|
27
30
|
- rvm: rbx-18mode
|
28
31
|
env: "TASK=test:rails RAILS=master"
|
32
|
+
- rvm: 1.8.7
|
33
|
+
env: "TASK=test:rails RAILS=4.0.0.beta1"
|
34
|
+
- rvm: jruby-18mode
|
35
|
+
env: "TASK=test:rails RAILS=4.0.0.beta1"
|
36
|
+
- rvm: rbx-18mode
|
37
|
+
env: "TASK=test:rails RAILS=4.0.0.beta1"
|
29
38
|
allow_failures:
|
30
39
|
- env: "TASK=test:rails RAILS=master"
|
40
|
+
- env: "TASK=test:rails RAILS=4.0.0.beta1"
|
31
41
|
- env: "TASK=test:sinatra SINATRA=master"
|
42
|
+
- env: "TASK=test:rails RAILS=3.0.20"
|
43
|
+
rvm: 2.0.0
|
32
44
|
- rvm: ruby-head
|
33
45
|
# Rails master needs newest bundler
|
34
46
|
before_install:
|
35
47
|
- ./kill-travis.sh
|
36
|
-
- gem
|
48
|
+
- gem update bundler
|
37
49
|
script: "bundle exec rake $TASK"
|
data/CHANGES
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
1.3.8
|
2
|
+
|
3
|
+
* Disable some superflous deprecation warnings
|
4
|
+
|
5
|
+
1.3.7
|
6
|
+
|
7
|
+
* Fixed issue #374, rescue and ensure blocks
|
8
|
+
* Fixed issue #333 (Throw syntax error if you write text after closed tag)
|
9
|
+
* Deprecated :attr_delimiter (renamed to :merge_attrs)
|
10
|
+
* Deprecated :attr_wrapper (renamed to :attr_quote)
|
11
|
+
* Warn if you use curly braces or brackets for ruby attributes since
|
12
|
+
curly braces and brackets will be interpreted as Hash/Array in Slim 2.0.0
|
13
|
+
Old syntax:
|
14
|
+
div id={person && person.id}
|
15
|
+
div id=[person && person.id]
|
16
|
+
New syntax in 2.0.0:
|
17
|
+
div id=(person && person.id)
|
18
|
+
* Deprecated :escape_quoted_attrs (done by default in 2.0)
|
19
|
+
* Warn if quoted attributes might be double escaped in Slim 2.0.0
|
20
|
+
Old syntax:
|
21
|
+
a href='http://slim-lang.com/?a=1&b=2'
|
22
|
+
a href=='http://slim-lang.com/?a=1&b=2'
|
23
|
+
New syntax in 2.0.0:
|
24
|
+
a href='http://slim-lang.com/?a=1&b=2'
|
25
|
+
a href=='http://slim-lang.com/?a=1&b=2'
|
26
|
+
* Improved pretty printing (Issue #202)
|
27
|
+
* Renamed Slim::EmbeddedEngine to Slim::Embedded (Old constant still available until 2.0)
|
28
|
+
* Renamed Slim::ControlStructures to Slim::Controls
|
29
|
+
* Tab expansion improved (tab + space is interpreted as equivalent to tab)
|
30
|
+
* Support for wrapping javascript in HTML comments or CDATA (Issue #340)
|
31
|
+
* Asciidoc embedded engine added
|
32
|
+
|
1
33
|
1.3.6
|
2
34
|
|
3
35
|
* Allow attribute values to be broken with `\` (Issue #331)
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org/'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
@@ -33,6 +33,14 @@ if ENV['SINATRA']
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
gem 'rake', '>= 0.8.7'
|
37
|
+
gem 'sass', '>= 3.1.0'
|
38
|
+
gem 'minitest'
|
39
|
+
gem 'kramdown'
|
40
|
+
gem 'creole'
|
41
|
+
gem 'builder'
|
42
|
+
gem 'asciidoctor'
|
43
|
+
|
36
44
|
if ENV['TASK'] == 'bench'
|
37
45
|
gem 'erubis'
|
38
46
|
gem 'haml'
|
data/README.md
CHANGED
@@ -1,28 +1,47 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/slim-template/slim.png?branch=master)](http://travis-ci.org/slim-template/slim) [![Dependency Status](https://gemnasium.com/slim-template/slim.png?travis)](https://gemnasium.com/slim-template/slim) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/slim-template/slim)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/slim.png)](http://rubygems.org/gems/slim) [![Build Status](https://secure.travis-ci.org/slim-template/slim.png?branch=master)](http://travis-ci.org/slim-template/slim) [![Dependency Status](https://gemnasium.com/slim-template/slim.png?travis)](https://gemnasium.com/slim-template/slim) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/slim-template/slim)
|
4
4
|
|
5
5
|
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.
|
6
6
|
|
7
7
|
A short list of the features...
|
8
8
|
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
* Highly configurable and extendable
|
17
|
-
*
|
9
|
+
* Elegant syntax
|
10
|
+
* Short syntax without closing tags (Using indentation instead)
|
11
|
+
* HTML style mode with closing tags
|
12
|
+
* Configurable shortcut tags (`#` for `<div id="...">` and `.` for `<div class="...">` in the default configuration)
|
13
|
+
* Safety
|
14
|
+
* Automatic HTML escaping by default
|
15
|
+
* Support for Rails' `html_safe?`
|
16
|
+
* Highly configurable and extendable via plugins
|
17
|
+
* Logic less mode similar to Mustache, realized as plugin
|
18
|
+
* Translator/I18n, realized as plugin
|
19
|
+
* High performance
|
20
|
+
* Comparable speed to ERB/Erubis
|
21
|
+
* Streaming support in Rails
|
18
22
|
* Supported by all major frameworks (Rails, Sinatra, ...)
|
19
|
-
*
|
23
|
+
* Embedded engines like Markdown and Textile
|
24
|
+
|
25
|
+
## Upgrade to version 2.0
|
26
|
+
|
27
|
+
__NOTE:__ Slim 2.0 is not yet released, but you can try the preview versions.
|
28
|
+
|
29
|
+
If you are already using Slim 1.3 or 1.2 and want to upgrade to the newest version 2.0, you should at first
|
30
|
+
upgrade to Slim 1.3.7 which will emit warnings for deprecated features. This way you can easily
|
31
|
+
see if your application is already Slim 2.0 compliant!
|
32
|
+
|
33
|
+
Slim 2.0 removes deprecated features from the 1.3 series and cleans up some minor
|
34
|
+
inconsistencies in the syntax (Attribute wrapper and quoted attribute escaping).
|
35
|
+
Of course it also includes new features and bugfixes. See the CHANGES for details.
|
36
|
+
|
37
|
+
In general don't be afraid of upgrading! We try to be backward compatible and follow [semantic versions](http://semver.org/)
|
38
|
+
as good as possible.
|
20
39
|
|
21
40
|
## Introduction
|
22
41
|
|
23
42
|
### What is Slim?
|
24
43
|
|
25
|
-
Slim is a fast, lightweight templating engine with support for __Rails
|
44
|
+
Slim is a fast, lightweight templating engine with support for __Rails 3 and 4__. It has been heavily tested on all major ruby implementations. We use
|
26
45
|
continous integration (travis-ci).
|
27
46
|
|
28
47
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
@@ -38,9 +57,12 @@ by the logic less plugin and the translator plugin which provides I18n.
|
|
38
57
|
|
39
58
|
Within the Rails community, _Erb_ and _Haml_ are without doubt the two most popular templating engines. However, _Erb_'s syntax is cumbersome and _Haml_'s syntax can be quite cryptic to the uninitiated.
|
40
59
|
|
60
|
+
There is also some development in logic-less engines (e.g. [Mustache](https://github.com/defunkt/mustache) which requires you to write standard HTML). You can also use Slim in logic-less mode if you like the Slim syntax to build your HTML but don't want to write Ruby in your templates.
|
61
|
+
|
41
62
|
Slim was born to bring a minimalist syntax approach with speed. If people chose not to use Slim, it would not be because of speed.
|
42
63
|
|
43
|
-
___Yes, Slim is speedy!___ Benchmarks are
|
64
|
+
___Yes, Slim is speedy!___ Benchmarks are done for every commit at {http://travis-ci.org/#!/slim-template/slim}.
|
65
|
+
Don't trust the numbers? That's as it should be. Please try the benchmark rake task yourself!
|
44
66
|
|
45
67
|
### How to start?
|
46
68
|
|
@@ -84,7 +106,7 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
84
106
|
|
85
107
|
div id="footer"
|
86
108
|
= render 'footer'
|
87
|
-
| Copyright © #{year} #{author}
|
109
|
+
| Copyright © #{@year} #{@author}
|
88
110
|
|
89
111
|
Indentation matters, but the indentation depth can be chosen as you like. If you want to first indent 2 spaces, then 5 spaces, it's your choice. To nest markup you only need to indent by one space, the rest is gravy.
|
90
112
|
|
@@ -380,7 +402,7 @@ as booleans. If you use the attribut wrapper you can omit the attribute assigmen
|
|
380
402
|
|
381
403
|
#### Attribute merging
|
382
404
|
|
383
|
-
You can configure attributes to be merged if multiple are given (See option `:
|
405
|
+
You can configure attributes to be merged if multiple are given (See option `:merge_attrs`). In the default configuration
|
384
406
|
this is done for class attributes with the white space as delimiter.
|
385
407
|
|
386
408
|
a.menu class="highlight" href="http://slim-lang.com/" Slim-lang.com
|
@@ -409,7 +431,7 @@ You can also use methods or instance variables which return a hash as shown here
|
|
409
431
|
.card *method_which_returns_hash = place.name
|
410
432
|
.card *@hash_instance_variable = place.name
|
411
433
|
|
412
|
-
The hash attributes which support attribute merging (see Slim option `:
|
434
|
+
The hash attributes which support attribute merging (see Slim option `:merge_attrs`) can be given as an `Array`
|
413
435
|
|
414
436
|
.first *{:class => [:second, :third]} Text
|
415
437
|
|
@@ -545,6 +567,7 @@ Supported engines:
|
|
545
567
|
<tr><td>less:</td><td>less</td><td>Compile time</td><td>Embed less css code and wrap in style tag</td></tr>
|
546
568
|
<tr><td>styl:</td><td>styl</td><td>Compile time</td><td>Embed stylus css code and wrap in style tag</td></tr>
|
547
569
|
<tr><td>coffee:</td><td>coffee-script</td><td>Compile time</td><td>Compile coffee script code and wrap in script tag</td></tr>
|
570
|
+
<tr><td>asciidoc:</td><td>asciidoctor</td><td>Compile time + Interpolation</td><td>Compile AsciiDoc code and interpolate #\{variables} in text</td></tr>
|
548
571
|
<tr><td>markdown:</td><td>redcarpet/rdiscount/kramdown</td><td>Compile time + Interpolation</td><td>Compile markdown code and interpolate #\{variables} in text</td></tr>
|
549
572
|
<tr><td>textile:</td><td>redcloth</td><td>Compile time + Interpolation</td><td>Compile textile code and interpolate #\{variables} in text</td></tr>
|
550
573
|
<tr><td>creole:</td><td>creole</td><td>Compile time + Interpolation</td><td>Compile creole code and interpolate #\{variables} in text</td></tr>
|
@@ -556,9 +579,9 @@ Supported engines:
|
|
556
579
|
</tbody>
|
557
580
|
</table>
|
558
581
|
|
559
|
-
The embedded engines can be configured in Slim by setting the options directly on the `Slim::
|
582
|
+
The embedded engines can be configured in Slim by setting the options directly on the `Slim::Embedded` filter. Example:
|
560
583
|
|
561
|
-
Slim::
|
584
|
+
Slim::Embedded.default_options[:markdown] = {:auto_ids => false}
|
562
585
|
|
563
586
|
## Configuring Slim
|
564
587
|
|
@@ -617,16 +640,17 @@ There are a lot of them but the good thing is, that Slim checks the configuratio
|
|
617
640
|
<tr><td>String</td><td>:encoding</td><td>"utf-8"</td><td>Set encoding of template</td></tr>
|
618
641
|
<tr><td>String</td><td>:default_tag</td><td>"div"</td><td>Default tag to be used if tag name is omitted</td></tr>
|
619
642
|
<tr><td>Hash</td><td>:shortcut</td><td>\{'.' => {:attr => 'class'}, '#' => {:attr => 'id'}}</td><td>Attribute shortcuts</td></tr>
|
620
|
-
<tr><td>Symbol
|
621
|
-
<tr><td>Symbol
|
643
|
+
<tr><td>Array<Symbol,String></td><td>:enable_engines</td><td>nil <i>(All enabled)</i></td><td>List of enabled embedded engines (whitelist)</td></tr>
|
644
|
+
<tr><td>Array<Symbol,String></td><td>:disable_engines</td><td>nil <i>(None disabled)</i></td><td>List of disabled embedded engines (blacklist)</td></tr>
|
622
645
|
<tr><td>Boolean</td><td>:disable_capture</td><td>false (true in Rails)</td><td>Disable capturing in blocks (blocks write to the default buffer </td></tr>
|
623
646
|
<tr><td>Boolean</td><td>:disable_escape</td><td>false</td><td>Disable automatic escaping of strings</td></tr>
|
624
|
-
<tr><td>Boolean</td><td>:escape_quoted_attrs</td><td>false</td><td>Escape quoted attributes
|
647
|
+
<tr><td>Boolean</td><td>:escape_quoted_attrs</td><td>false</td><td>Escape quoted attributes. <b>Option is removed and activated per default in Slim 2.0!</b></td></tr>
|
625
648
|
<tr><td>Boolean</td><td>:use_html_safe</td><td>false (true in Rails)</td><td>Use String#html_safe? from ActiveSupport (Works together with :disable_escape)</td></tr>
|
626
649
|
<tr><td>Symbol</td><td>:format</td><td>:xhtml</td><td>HTML output format (Possible formats :xhtml, :html4, :html5, :html)</td></tr>
|
627
|
-
<tr><td>String</td><td>:
|
628
|
-
<tr><td>Hash</td><td>:
|
650
|
+
<tr><td>String</td><td>:attr_quote</td><td>'"'</td><td>Character to wrap attributes in html (can be ' or ")</td></tr>
|
651
|
+
<tr><td>Hash</td><td>:merge_attrs</td><td>\{'class' => ' '}</td><td>Joining character used if multiple html attributes are supplied (e.g. class="class1 class2")</td></tr>
|
629
652
|
<tr><td>Boolean</td><td>:sort_attrs</td><td>true</td><td>Sort attributes by name</td></tr>
|
653
|
+
<tr><td>Symbol</td><td>:js_wrapper</td><td>nil</td><td>Wrap javascript by :comment, :cdata or :both. You can also :guess the wrapper based on :format.</td></tr>
|
630
654
|
<tr><td>Boolean</td><td>:pretty</td><td>false</td><td>Pretty html indenting <b>(This is slower!)</b></td></tr>
|
631
655
|
<tr><td>String</td><td>:indent</td><td>' '</td><td>Indentation string</td></tr>
|
632
656
|
<tr><td>Boolean</td><td>:streaming</td><td>false (true in Rails > 3.1)</td><td>Enable output streaming</td></tr>
|
@@ -764,7 +788,7 @@ and activate logic less mode per render call in your application
|
|
764
788
|
<tbody>
|
765
789
|
<tr><td>Boolean</td><td>:logic_less</td><td>true</td><td>Enable logic less mode (Enabled if 'slim/logic_less' is required)</td></tr>
|
766
790
|
<tr><td>String</td><td>:dictionary</td><td>"self"</td><td>Dictionary where variables are looked up</td></tr>
|
767
|
-
<tr><td>Symbol/Array
|
791
|
+
<tr><td>Symbol/Array<Symbol></td><td>:dictionary_access</td><td>[:symbol, :string, :method, :instance_variable]</td><td>Dictionary access order (:symbol, :string, :method, :instance_variable)</td></tr>
|
768
792
|
</tbody>
|
769
793
|
</table>
|
770
794
|
|
@@ -837,7 +861,7 @@ Then just use the .slim extension and you're good to go.
|
|
837
861
|
|
838
862
|
#### Streaming
|
839
863
|
|
840
|
-
HTTP streaming is enabled
|
864
|
+
HTTP streaming is enabled by default if you use a Rails version which supports it.
|
841
865
|
|
842
866
|
## Tools
|
843
867
|
|
@@ -944,12 +968,7 @@ Work your magic and then submit a pull request. We love pull requests!
|
|
944
968
|
|
945
969
|
Please remember to test against Ruby versions 1.9.2 and 1.8.7.
|
946
970
|
|
947
|
-
If you find the documentation lacking (and you probably will), help us out
|
948
|
-
The docs are located in the gh-pages branch:
|
949
|
-
|
950
|
-
$ git checkout gh-pages
|
951
|
-
|
952
|
-
If you don't have the time to work on Slim, but found something we should know about, please submit an issue.
|
971
|
+
If you find the documentation lacking (and you probably will), 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.
|
953
972
|
|
954
973
|
## License
|
955
974
|
|
@@ -973,7 +992,7 @@ Template compilation framework:
|
|
973
992
|
|
974
993
|
Framework support:
|
975
994
|
|
976
|
-
* [Rails
|
995
|
+
* [Rails generators (slim-rails)](https://github.com/slim-template/slim-rails)
|
977
996
|
|
978
997
|
Syntax highlighting:
|
979
998
|
|
data/lib/slim.rb
CHANGED
@@ -2,9 +2,9 @@ require 'temple'
|
|
2
2
|
require 'slim/parser'
|
3
3
|
require 'slim/filter'
|
4
4
|
require 'slim/end_inserter'
|
5
|
-
require 'slim/
|
5
|
+
require 'slim/embedded'
|
6
6
|
require 'slim/interpolation'
|
7
|
-
require 'slim/
|
7
|
+
require 'slim/controls'
|
8
8
|
require 'slim/splat_attributes'
|
9
9
|
require 'slim/code_attributes'
|
10
10
|
require 'slim/engine'
|
data/lib/slim/code_attributes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Slim
|
2
2
|
# @api private
|
3
3
|
class CodeAttributes < Filter
|
4
|
-
define_options :
|
4
|
+
define_options :merge_attrs
|
5
5
|
|
6
6
|
# Handle attributes expression `[:html, :attrs, *attrs]`
|
7
7
|
#
|
@@ -17,7 +17,7 @@ module Slim
|
|
17
17
|
# @param [Array] value Value expression
|
18
18
|
# @return [Array] Compiled temple expression
|
19
19
|
def on_html_attr(name, value)
|
20
|
-
unless value[0] == :slim && value[1] == :attrvalue && !options[:
|
20
|
+
unless value[0] == :slim && value[1] == :attrvalue && !options[:merge_attrs][name]
|
21
21
|
# We perform merging on the attribute
|
22
22
|
@attr = name
|
23
23
|
return super
|
@@ -48,7 +48,7 @@ module Slim
|
|
48
48
|
# @return [Array] Compiled temple expression
|
49
49
|
def on_slim_attrvalue(escape, code)
|
50
50
|
# We perform attribute merging on Array values
|
51
|
-
if delimiter = options[:
|
51
|
+
if delimiter = options[:merge_attrs][@attr]
|
52
52
|
tmp = unique_name
|
53
53
|
[:multi,
|
54
54
|
[:code, "#{tmp} = #{code}"],
|
data/lib/slim/command.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'slim
|
2
|
-
require 'slim/translator'
|
1
|
+
require 'slim'
|
3
2
|
require 'optparse'
|
4
3
|
|
5
4
|
module Slim
|
6
|
-
Engine.set_default_options :
|
7
|
-
:pretty => false,
|
8
|
-
:tr => false
|
5
|
+
Engine.set_default_options :pretty => false
|
9
6
|
|
10
7
|
# Slim commandline interface
|
11
8
|
# @api private
|
@@ -51,11 +48,11 @@ module Slim
|
|
51
48
|
end
|
52
49
|
|
53
50
|
opts.on('-t', '--translator', 'Enable translator plugin') do
|
54
|
-
|
51
|
+
require 'slim/translator'
|
55
52
|
end
|
56
53
|
|
57
54
|
opts.on('-l', '--logic-less', 'Enable logic less plugin') do
|
58
|
-
|
55
|
+
require 'slim/logic_less'
|
59
56
|
end
|
60
57
|
|
61
58
|
opts.on('-p', '--pretty', 'Produce pretty html') do
|
@@ -60,7 +60,7 @@ module Slim
|
|
60
60
|
|
61
61
|
# Temple filter which processes embedded engines
|
62
62
|
# @api private
|
63
|
-
class
|
63
|
+
class Embedded < Filter
|
64
64
|
@engines = {}
|
65
65
|
|
66
66
|
# Register embedded engine
|
@@ -155,7 +155,7 @@ module Slim
|
|
155
155
|
:style => options[:pretty] ? :expanded : :compressed,
|
156
156
|
:cache => false)) { text }.render
|
157
157
|
text.chomp!
|
158
|
-
[:static,
|
158
|
+
[:static, text]
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
@@ -221,6 +221,18 @@ module Slim
|
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
|
+
# Javascript wrapper engine.
|
225
|
+
# Like TagEngine, but can wrap content in html comment or cdata.
|
226
|
+
class JavaScriptEngine < TagEngine
|
227
|
+
disable_option_validator!
|
228
|
+
|
229
|
+
set_default_options :tag => :script, :attributes => { :type => 'text/javascript' }
|
230
|
+
|
231
|
+
def on_slim_embedded(engine, body)
|
232
|
+
super(engine, [:html, :js, body])
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
224
236
|
# Embeds ruby code
|
225
237
|
class RubyEngine < Engine
|
226
238
|
def on_slim_embedded(engine, body)
|
@@ -229,6 +241,7 @@ module Slim
|
|
229
241
|
end
|
230
242
|
|
231
243
|
# These engines are executed at compile time, embedded ruby is interpolated
|
244
|
+
register :asciidoc, InterpolateTiltEngine
|
232
245
|
register :markdown, InterpolateTiltEngine
|
233
246
|
register :textile, InterpolateTiltEngine
|
234
247
|
register :rdoc, InterpolateTiltEngine
|
@@ -237,7 +250,7 @@ module Slim
|
|
237
250
|
register :mediawiki, InterpolateTiltEngine
|
238
251
|
|
239
252
|
# These engines are executed at compile time
|
240
|
-
register :coffee,
|
253
|
+
register :coffee, JavaScriptEngine, :engine => StaticTiltEngine
|
241
254
|
register :less, TagEngine, :tag => :style, :attributes => { :type => 'text/css' }, :engine => StaticTiltEngine
|
242
255
|
register :styl, TagEngine, :tag => :style, :attributes => { :type => 'text/css' }, :engine => StaticTiltEngine
|
243
256
|
register :sass, TagEngine, :pretty, :tag => :style, :attributes => { :type => 'text/css' }, :engine => SassEngine
|
@@ -249,10 +262,16 @@ module Slim
|
|
249
262
|
register :builder, PrecompiledTiltEngine
|
250
263
|
|
251
264
|
# Embedded javascript/css
|
252
|
-
register :javascript,
|
265
|
+
register :javascript, JavaScriptEngine
|
253
266
|
register :css, TagEngine, :tag => :style, :attributes => { :type => 'text/css' }
|
254
267
|
|
255
268
|
# Embedded ruby code
|
256
269
|
register :ruby, RubyEngine
|
257
270
|
end
|
271
|
+
|
272
|
+
def self.const_missing(name)
|
273
|
+
super unless name == :EmbeddedEngine
|
274
|
+
warn 'Slim::EmbeddedEngine is deprecated, it is called Slim::Embedded in Slim 2.0'
|
275
|
+
Embedded
|
276
|
+
end
|
258
277
|
end
|
data/lib/slim/end_inserter.rb
CHANGED