slim 3.0.2 → 3.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40ec0b5a06448c8dd50ccf5b2113fce5b14c2ce2
4
- data.tar.gz: 9b34f912436340d0e603eeb342ac5f3cd93c188c
3
+ metadata.gz: 3526425b78d5829bd231ac9a41146c6044b093d3
4
+ data.tar.gz: fe4ab15abda376d89008704a2956e2c5e7050f99
5
5
  SHA512:
6
- metadata.gz: 5405f3254bfa3edba989203f191a8f8069fdf075ca4428ed173fbbdc40ca83061739c065e3a45c3fc765e1979015ad2969ac84eab93ba8075cf7aecf00fe4530
7
- data.tar.gz: 66231d7ee04b5c03dae4f1497045d3345bbff266b5176f593f91f38fe83d8789fd956d93e9a3dea639d17e20dcd967ed8c661d754ad173173eaf9e880dfff287
6
+ metadata.gz: fa521d0745c0b0a404c512fc22a9dd69643efcfec0827e500ef6b5ad183ef9fdda8a163550ece9ae9d2d7ecbddd3ac32fa13a0edcfdaf824bd4076950c9eb6d4
7
+ data.tar.gz: caacf25c2529313fbf6aad2de36e6f5186de76b873819d214f39d982d3e91da7105f1d46ddf144e852f25a53f040ac20c3d8a45ea60c1abcba1967bfd3955b4a
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 3.0.3
2
+
3
+ * Fix #392, capturing for splat attributes didn't work correctly under Rails
4
+
1
5
  3.0.2
2
6
 
3
7
  * slimrb: Add option --locals
@@ -33,8 +33,8 @@ Slim は 不可解にならないように view の構文を本質的な部品
33
33
  * バグ: <http://github.com/slim-template/slim/issues>
34
34
  * リスト: <http://groups.google.com/group/slim-template>
35
35
  * API ドキュメント:
36
- * 最新の Gem: <http://rubydoc.info/gems/slim/frames>
37
- * GitHub master: <http://rubydoc.info/github/slim-template/slim/master/frames>
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>
38
38
 
39
39
  ## イントロダクション
40
40
 
data/README.md CHANGED
@@ -33,8 +33,8 @@ A short list of the features...
33
33
  * Bugs: <http://github.com/slim-template/slim/issues>
34
34
  * List: <http://groups.google.com/group/slim-template>
35
35
  * API documentation:
36
- * Latest Gem: <http://rubydoc.info/gems/slim/frames>
37
- * GitHub master: <http://rubydoc.info/github/slim-template/slim/master/frames>
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>
38
38
 
39
39
  ## Introduction
40
40
 
@@ -36,11 +36,30 @@ module Slim
36
36
  end
37
37
  end
38
38
 
39
- def build_tag
39
+ def build_tag(&block)
40
40
  tag = @attrs.delete('tag').to_s
41
41
  tag = @options[:default_tag] if tag.empty?
42
- if block_given?
43
- "<#{tag}#{build_attrs}>#{yield}</#{tag}>"
42
+ if block
43
+ # This is a bit of a hack to get a universal capturing.
44
+ #
45
+ # TODO: Add this as a helper somewhere to solve these capturing issues
46
+ # once and for all.
47
+ #
48
+ # If we have Slim capturing disabled and the scope defines the method `capture` (i.e. Rails)
49
+ # we use this method to capture the content.
50
+ #
51
+ # otherwise we just use normal Slim capturing (yield).
52
+ #
53
+ # See https://github.com/slim-template/slim/issues/591
54
+ # https://github.com/slim-template/slim#helpers-capturing-and-includes
55
+ #
56
+ content =
57
+ if @options[:disable_capture] && (scope = block.binding.eval('self')).respond_to?(:capture)
58
+ scope.capture(&block)
59
+ else
60
+ yield
61
+ end
62
+ "<#{tag}#{build_attrs}>#{content}</#{tag}>"
44
63
  else
45
64
  "<#{tag}#{build_attrs} />"
46
65
  end
@@ -2,7 +2,7 @@ module Slim
2
2
  module Splat
3
3
  # @api private
4
4
  class Filter < ::Slim::Filter
5
- define_options :merge_attrs, :attr_quote, :sort_attrs, :default_tag, :format,
5
+ define_options :merge_attrs, :attr_quote, :sort_attrs, :default_tag, :format, :disable_capture,
6
6
  hyphen_attrs: %w(data aria), use_html_safe: ''.respond_to?(:html_safe?)
7
7
 
8
8
  def call(exp)
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  # Slim version string
3
3
  # @api public
4
- VERSION = '3.0.2'
4
+ VERSION = '3.0.3'
5
5
  end
@@ -0,0 +1,2 @@
1
+ #splat
2
+ *{tag: 'splat'} Hello
@@ -82,4 +82,9 @@ class TestSlim < ActionDispatch::IntegrationTest
82
82
  assert_match %r{<label><b>Name</b></label>}, @response.body
83
83
  assert_xpath '//input[@id="entry_name" and @name="entry[name]" and @type="text"]'
84
84
  end
85
+
86
+ test "splat" do
87
+ get "/slim/splat"
88
+ assert_html "<div id=\"splat\"><splat>Hello</splat></div>"
89
+ end
85
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Mendler
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-02 00:00:00.000000000 Z
13
+ date: 2015-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: temple
@@ -157,6 +157,7 @@ files:
157
157
  - test/rails/app/views/slim/no_layout.html.slim
158
158
  - test/rails/app/views/slim/normal.html.slim
159
159
  - test/rails/app/views/slim/partial.html.slim
160
+ - test/rails/app/views/slim/splat.html.slim
160
161
  - test/rails/app/views/slim/thread_options.html.slim
161
162
  - test/rails/app/views/slim/variables.html.slim
162
163
  - test/rails/app/views/slim/xml.slim