Class: Archangel::RenderService
- Inherits:
-
Object
- Object
- Archangel::RenderService
- Defined in:
- app/services/archangel/render_service.rb
Overview
Liquid render service
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assigns ⇒ Object
readonly
Variable assignments.
-
#local_filters ⇒ Object
readonly
Local filters.
-
#local_registers ⇒ Object
readonly
Local registers.
-
#template ⇒ Object
readonly
Template to Liquidize.
Class Method Summary collapse
-
.call(template, assigns = {}, options = {}) ⇒ String
Render the Liquid content.
Instance Method Summary collapse
-
#call ⇒ String
Render the Liquid content.
-
#initialize(template, assigns = {}, options = {}) ⇒ RenderService
constructor
Liquid renderer.
Constructor Details
#initialize(template, assigns = {}, options = {}) ⇒ RenderService
Liquid renderer
35 36 37 38 39 40 |
# File 'app/services/archangel/render_service.rb', line 35 def initialize(template, assigns = {}, = {}) @template = template @assigns = assigns @local_filters = .fetch(:filters, []) @local_registers = .fetch(:registers, {}) end |
Instance Attribute Details
#assigns ⇒ Object (readonly)
Variable assignments
11 12 13 |
# File 'app/services/archangel/render_service.rb', line 11 def assigns @assigns end |
#local_filters ⇒ Object (readonly)
Local filters
16 17 18 |
# File 'app/services/archangel/render_service.rb', line 16 def local_filters @local_filters end |
#local_registers ⇒ Object (readonly)
Local registers
21 22 23 |
# File 'app/services/archangel/render_service.rb', line 21 def local_registers @local_registers end |
#template ⇒ Object (readonly)
Template to Liquidize
26 27 28 |
# File 'app/services/archangel/render_service.rb', line 26 def template @template end |
Class Method Details
.call(template, assigns = {}, options = {}) ⇒ String
Render the Liquid content
50 51 52 |
# File 'app/services/archangel/render_service.rb', line 50 def self.call(template, assigns = {}, = {}) new(template, assigns, ).call end |
Instance Method Details
#call ⇒ String
Render the Liquid content
59 60 61 62 |
# File 'app/services/archangel/render_service.rb', line 59 def call liquid = ::Liquid::Template.parse(template) liquid.send(:render, stringify_assigns, ).html_safe end |