17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/services/landable/render_service.rb', line 17
def render!
variables = options[:responder].try(:controller).try(:fetch_landable_variables)
variables ||= {}
content = render_template(page.body, variables, registers: {
page: page,
assets: assets_for_page,
responder: options[:responder],
})
if layout?
content = render_template(theme.body, {'body' => content}, registers: {
page: page,
assets: assets_for_theme,
})
end
if options[:preview]
if page.html?
preview_template = File.open(Landable::Engine.root.join('app', 'views', 'templates', 'preview.liquid')).read
content = render_template(preview_template, {
'content' => content,
'is_redirect' => page.redirect?,
'is_html' => page.html?,
'status_code' => page.status_code,
'redirect_url' => page.redirect_url,
})
else
content = '<pre>' + CGI::escapeHTML(content) + '</pre>'
end
end
content
end
|