Module: ActionViewHelpers

Defined in:
lib/scribo/action_view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#layout_with_scribo(layout_name, yield_content) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/scribo/action_view_helpers.rb', line 6

def layout_with_scribo(layout_name, yield_content)
  options = { request: request, uri: URI.parse(request.original_url), host: request.host, path: URI.parse(request.original_url).path }
  site = Scribo::SiteFindService.new(options).call

  application_js = content_for?(:js) && content_for(:js)

  content = site.contents.new(kind: 'text', data: yield_content, properties: { layout: layout_name })

  registers = { controller: controller, application_assets: scribo_application_assets, application_js: application_js }
  Scribo::ContentRenderService.new(content, self, registers: registers).call.html_safe
end