class Pulitzer::GeneratorElementType

Public Class Methods

new(element_type) click to toggle source
# File lib/generators/pulitzer/post_type_generator.rb, line 5
def initialize(element_type)
  case element_type.class.name
  when "Pulitzer::PostTypeContentElementType"
    @label = element_type.label
    @kind = 'content_element'
    @optional = !element_type.required
  when 'Pulitzer::FreeFormSectionType'
    @label = element_type.name
    @kind = 'free_form_section'
  end
end

Public Instance Methods

content_element_injection_content() click to toggle source
# File lib/generators/pulitzer/post_type_generator.rb, line 22
def content_element_injection_content
  content = ''
  if @optional
    content += "  <% if cms_content_present? @post.content_element('#{@label}') %>\n  "
  end
  content +=   "    <%= render_cms_element @post.content_element('#{@label}') %>\n"
  if @optional
    content += "  <% end %>\n"
  end
  content
end
free_form_section_injection_content() click to toggle source
# File lib/generators/pulitzer/post_type_generator.rb, line 34
    def free_form_section_injection_content
      <<-VIEW
  <%= render_cms_section(@post, '#{@label}') %>

      VIEW
    end
injection_content() click to toggle source
# File lib/generators/pulitzer/post_type_generator.rb, line 17
def injection_content
  injection_content_method = "#{@kind}_injection_content"
  send injection_content_method
end