rails-presenter 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_presenter/base.rb +27 -2
- data/lib/rails_presenter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1187d84b167f923d52a8ddccb57fd0b310edfc2e
|
4
|
+
data.tar.gz: ffa4fb67f693da74fdbc76225a8f1c8d01ef50d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d36f09420ee59ca8a4af9a1517db76a5f3e39b0a9bfb91689c22b68537576d4f8af700a5d12071db062fad388be0ea129594b5280b7e76a6d55a57ed6d3b78
|
7
|
+
data.tar.gz: fe8f01219dbc56910d3e930e378547ae8059788f7e6ac8cc50f5ae5902b87de96362632dc669b58027edd00629522ae377bf6c6d8af3f0dd0ab1514b104894bc
|
data/lib/rails_presenter/base.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
class RailsPresenter::Base
|
2
|
-
include ActionView::Context
|
3
|
-
|
2
|
+
include ActionView::Context # fix output_buffer to be able to capture yielded block
|
3
|
+
if defined? Haml
|
4
|
+
include Haml::Helpers # add capture_haml support
|
5
|
+
end
|
6
|
+
include Sprockets::Rails::Helper # add asset pipeline support
|
4
7
|
def initialize
|
5
8
|
self.debug_assets = Rails.application.config.assets.debug
|
6
9
|
self.digest_assets = Rails.application.config.assets.digest
|
@@ -12,4 +15,26 @@ class RailsPresenter::Base
|
|
12
15
|
def t(*args)
|
13
16
|
I18n.t(*args)
|
14
17
|
end
|
18
|
+
|
19
|
+
def capture_haml(*args, &block)
|
20
|
+
buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer
|
21
|
+
with_haml_buffer(buffer) do
|
22
|
+
position = haml_buffer.buffer.length
|
23
|
+
|
24
|
+
haml_buffer.capture_position = position
|
25
|
+
value = block.call(*args)
|
26
|
+
|
27
|
+
captured = haml_buffer.buffer.slice!(position..-1)
|
28
|
+
|
29
|
+
if captured == '' and value != haml_buffer.buffer
|
30
|
+
captured = (value.is_a?(String) ? value : nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
return nil if captured.nil?
|
34
|
+
return (haml_buffer.options[:ugly] ? captured : prettify(captured))
|
35
|
+
end
|
36
|
+
# https://github.com/haml/haml/issues/822
|
37
|
+
#ensure
|
38
|
+
#haml_buffer.capture_position = nil
|
39
|
+
end
|
15
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Jobin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|