Class: Archangel::RenderService

Inherits:
Object
  • Object
show all
Defined in:
app/services/archangel/render_service.rb

Overview

Liquid render service

Direct Known Subclasses

DesignRenderService

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @template = template
  @assigns = assigns
  @local_filters = options.fetch(:filters, [])
  @local_registers = options.fetch(:registers, {})
end

Instance Attribute Details

#assignsObject (readonly)

Variable assignments


11
12
13
# File 'app/services/archangel/render_service.rb', line 11

def assigns
  @assigns
end

#local_filtersObject (readonly)

Local filters


16
17
18
# File 'app/services/archangel/render_service.rb', line 16

def local_filters
  @local_filters
end

#local_registersObject (readonly)

Local registers


21
22
23
# File 'app/services/archangel/render_service.rb', line 21

def local_registers
  @local_registers
end

#templateObject (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 = {}, options = {})
  new(template, assigns, options).call
end

Instance Method Details

#callString

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, liquid_options).html_safe
end