cadmus 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25c8b4e53cfd255b409c868f3b8d713ee9ba529f
4
- data.tar.gz: 0d63afd6ffe03f07c80b2e9a6ff6acfd8285c429
3
+ metadata.gz: baa8f826659300b741b1fac079ee71bb74315514
4
+ data.tar.gz: 1422e3236c83edcc178b76867f568e4cd4122149
5
5
  SHA512:
6
- metadata.gz: fa374b8cf36fd744d00c382eb62b64f013b53b5ea9a2ce30df22f640b4bcd56e85e3f3d98da8c9b8393d26738c2c6dff32c610ed0f6cbd16b7fafcd741850b1f
7
- data.tar.gz: 6343c1b8a254081c5e2613665534af3cfda9a44837067b02c374916a87dc143a7ed975c1b4ac4c9a1ee7be35d249f13c03928033b93620c0b7d0ccbf32ec80ed
6
+ metadata.gz: e8e8447ace4df8e75b8910fb9d2d6f5e50b39200fd91a264f497122326aa38c66c3c07a827085f5b0431399a45564e35a5723c1822db1f35b718141f44d34a95
7
+ data.tar.gz: 47f2c14c40f57c03a5b4b22284245c6f3b69c37a067fc2c78cbaaecc35aa1f47fc9ac7b2f81f8dc5ad8de383bcc98af1df33bfc1e7101deca9dc62f469385ac1
@@ -1,3 +1,7 @@
1
+ ## cadmus 0.5.3 (02-04-2017)
2
+
3
+ * Make it possible to make `liquid_assigns`, `liquid_filters` and `liquid_registers` private or protected methods in controllers and other Renderables.
4
+
1
5
  ## cadmus 0.5.2 (11-10-2016)
2
6
 
3
7
  * Rails 5 compatibility fixes
@@ -1,5 +1,5 @@
1
1
  module Cadmus
2
-
2
+
3
3
  # A Cadmus renderer is an object that handles the rendering of +Liquid::Template+s to output formats
4
4
  # such as HTML or plain text. A renderer provides several features over and above what plain
5
5
  # Liquid does:
@@ -9,22 +9,22 @@ module Cadmus
9
9
  # * Ability to specify default assigns, filters, and registers and augment them on a per-call basis
10
10
  # * Ability to render to multiple output formats from a single renderer
11
11
  module Renderers
12
-
12
+
13
13
  # The simplest Cadmus renderer. It will render Liquid templates to HTML and plain text (removing the
14
14
  # HTML tags from the plain text output).
15
15
  class Base
16
16
  attr_accessor :default_assigns, :default_filters, :default_registers, :html_sanitizer
17
-
17
+
18
18
  DEFAULT_HTML_SANITIZER = defined?(Rails::Html::FullSanitizer) ? Rails::Html::FullSanitizer : HTML::FullSanitizer
19
-
19
+
20
20
  def initialize
21
21
  self.default_registers = {}
22
22
  self.default_filters = []
23
23
  self.default_assigns = {}
24
-
24
+
25
25
  self.html_sanitizer = Rails.application.config.action_view.full_sanitizer || DEFAULT_HTML_SANITIZER.new
26
26
  end
27
-
27
+
28
28
  # The preprocess method performs the initial rendering of the Liquid template using the a combination
29
29
  # of the default_filters, default_assigns, default_registers, and any :assigns, :filters, and :registers
30
30
  # options passed in as options.
@@ -38,18 +38,18 @@ module Cadmus
38
38
  # @option options [Hash] :registers additional register variables that will be made available to the template.
39
39
  # @option options [Hash] :filters additional filters to be made available to the template.
40
40
  # @return [String] the raw results of rendering the Liquid template.
41
- def preprocess(template, format, options={})
41
+ def preprocess(template, format, options={})
42
42
  render_args = [
43
- default_assigns.merge(options[:assigns] || {}),
44
- {
43
+ default_assigns.merge(options[:assigns] || {}),
44
+ {
45
45
  :filters => default_filters + (options[:filters] || []),
46
46
  :registers => default_registers.merge(options[:registers] || {})
47
47
  }
48
- ]
49
-
48
+ ]
49
+
50
50
  template.render(*render_args)
51
51
  end
52
-
52
+
53
53
  # Render a given Liquid template to the specified format. This renderer implementation supports +:html+ and
54
54
  # +:text+ formats, but other implementations may support other formats.
55
55
  #
@@ -61,7 +61,7 @@ module Cadmus
61
61
  # available options.
62
62
  def render(template, format, options={})
63
63
  content = preprocess(template, format, options)
64
-
64
+
65
65
  case format.to_sym
66
66
  when :html
67
67
  content.html_safe
@@ -73,7 +73,7 @@ module Cadmus
73
73
  end
74
74
  end
75
75
  end
76
-
76
+
77
77
  # A helper module that can be included in classes that wish to provide a Cadmus renderer. For
78
78
  # example, an Email class might want to provide a renderer so that it can be easily transformed
79
79
  # into HTML or text formats.
@@ -98,27 +98,27 @@ module Cadmus
98
98
  # end
99
99
  # end
100
100
  module Renderable
101
-
101
+
102
102
  # @return a new Cadmus renderer set up using the +default_assigns+, +default_registers+
103
103
  # and +default_filters+ methods, if they exist.
104
104
  def cadmus_renderer
105
105
  cadmus_renderer_class.new.tap { |renderer| setup_renderer(renderer) }
106
106
  end
107
-
107
+
108
108
  # @return the Cadmus renderer class to instanciate in the +cadmus_renderer+ method. By
109
109
  # default, Cadmus::Renderers::Base.
110
110
  def cadmus_renderer_class
111
111
  Cadmus::Renderers::Base
112
112
  end
113
-
113
+
114
114
  protected
115
115
  # Sets the values of +default_assigns+, +default_registers+ and +default_filters+ on a given
116
116
  # renderer using the +liquid_assigns+, +liquid_registers+ and +liquid_filters+ methods, if
117
117
  # they're defined.
118
118
  def setup_renderer(renderer)
119
- renderer.default_assigns = liquid_assigns if respond_to?(:liquid_assigns)
120
- renderer.default_registers = liquid_registers if respond_to?(:liquid_registers)
121
- renderer.default_filters = liquid_filters if respond_to?(:liquid_filters)
119
+ renderer.default_assigns = liquid_assigns if respond_to?(:liquid_assigns, true)
120
+ renderer.default_registers = liquid_registers if respond_to?(:liquid_registers, true)
121
+ renderer.default_filters = liquid_filters if respond_to?(:liquid_filters, true)
122
122
  end
123
123
  end
124
124
  end
@@ -1,3 +1,3 @@
1
1
  module Cadmus
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cadmus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-10 00:00:00.000000000 Z
12
+ date: 2017-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails