class Vueport::Renderer

Constants

CONTENT_WRAPPER_ID
TEMPLATE_ID

Attributes

content[RW]
path[RW]

Public Class Methods

new(content, path: '/') click to toggle source
# File lib/vueport/renderer.rb, line 10
def initialize(content, path: '/')
  self.content = content
  self.path = path
end

Public Instance Methods

render() click to toggle source
# File lib/vueport/renderer.rb, line 15
def render
  safe_join [rendered_content, template]
end

Private Instance Methods

rendered_content() click to toggle source
# File lib/vueport/renderer.rb, line 21
def rendered_content
  ssr_enabled? ? ssr_content : wrapper
end
ssr_content() click to toggle source
# File lib/vueport/renderer.rb, line 29
def ssr_content
  Vueport::NodeClient.new(wrapper(content), path: path).run!
rescue
  wrapper
end
ssr_enabled?() click to toggle source
# File lib/vueport/renderer.rb, line 39
def ssr_enabled?
  Vueport.config[:ssr_enabled]
end
template() click to toggle source
# File lib/vueport/renderer.rb, line 25
def template
  content_tag :script, wrapper(content), type: 'text/x-template', id: TEMPLATE_ID
end
wrapper(inner = '') click to toggle source
# File lib/vueport/renderer.rb, line 35
def wrapper(inner = '')
  content_tag :div, inner, id: CONTENT_WRAPPER_ID, 'v-bind:class' => 'wrapperClass'
end