Module: Pageflow::PageTypesHelper

Includes:
RenderJsonHelper
Defined in:
app/helpers/pageflow/page_types_helper.rb

Constant Summary

Constants included from RenderJsonHelper

RenderJsonHelper::ESCAPED_CHARS, RenderJsonHelper::ESCAPED_CHARS_REGEX

Instance Method Summary collapse

Methods included from RenderJsonHelper

#render_html_partial, #render_json, #render_json_partial, #render_json_seed, #sanitize_json

Instance Method Details

#page_type_json_seed(json, page_type) ⇒ Object



11
12
13
14
15
# File 'app/helpers/pageflow/page_types_helper.rb', line 11

def page_type_json_seed(json, page_type)
  if page_type.json_seed_template
    json.partial!(template: page_type.json_seed_template, locals: {page_type: page_type})
  end
end

#page_type_json_seeds(config) ⇒ Object



5
6
7
8
9
# File 'app/helpers/pageflow/page_types_helper.rb', line 5

def page_type_json_seeds(config)
  render_json_partial('pageflow/page_types/page_type',
                      collection: config.page_types.to_a,
                      as: :page_type)
end

#page_type_templates(entry) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/pageflow/page_types_helper.rb', line 17

def page_type_templates(entry)
  # Required by RevisionFileHelper#find_file_in_entry
  @entry = entry

  safe_join(Pageflow.config.page_types.map do |page_type|
    (:script,
                render(template: page_type.template_path,
                       locals: {
                         configuration: {},
                         page: Page.new,
                         entry: entry
                       },
                       layout: false).to_str,
                type: 'text/html', data: {template: "#{page_type.name}_page"})
  end)
end