Class: Archangel::LiquidView

Inherits:
Object
  • Object
show all
Defined in:
lib/archangel/liquid_view.rb

Overview

Liquid view renderer

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ LiquidView

Liquid view

Parameters:

  • view (String)

    the view


13
14
15
# File 'lib/archangel/liquid_view.rb', line 13

def initialize(view)
  @view = view
end

Class Method Details

.call(template) ⇒ String

Render Liquid content

Parameters:

  • template (String)

    the content

Returns:

  • (String)

    the rendered content


23
24
25
26
# File 'lib/archangel/liquid_view.rb', line 23

def self.call(template)
  "Archangel::LiquidView.new(self).render(
    #{template.source.inspect}, local_assigns)"
end

Instance Method Details

#render(template, local_assigns = {}) ⇒ String

Render Liquid content

Parameters:

  • template (String)

    the content

  • local_assigns (Hash) (defaults to: {})

    the local assigned variables

Returns:

  • (String)

    the rendered content


35
36
37
38
39
40
41
42
# File 'lib/archangel/liquid_view.rb', line 35

def render(template, local_assigns = {})
  default_controller.headers["Content-Type"] ||= "text/html; charset=utf-8"

  assigns = default_assigns(local_assigns)
  options = { registers: default_registers }

  Archangel::RenderService.call(template, assigns, options)
end