Method: Cms::FormBuilder#cms_template_editor

Defined in:
app/helpers/cms/form_builder.rb

#cms_template_editor(method, options = {}) ⇒ Object

Renders a template editor that allows developers to edit the view used to render a specific block. Render both a ‘Handler’ select box (erb, builder, etc) and a text_area for editing. Will not display the editor if the underlying object is marked as ‘render_inline(false)’. This allows developers to edit the render.html.erb directly to update how the model displays.

For example, Portlets will often specify a :template to allow runtime update of their view.

Options:

:default_handler - Which handler will be the default when creating new instances. (Defaults to erb)
:instructions - Instructions that will be displayed below the text area. (Blank by default)
:label - The name for the label (Defaults to humanized version of field name)


174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'app/helpers/cms/form_builder.rb', line 174

def cms_template_editor(method, options={})
  if object.class.render_inline

    # Set some defaults
    options[:default_value] = @object.class.default_template
    set_default_value!(method, options)
    options[:default_handler] = "erb" unless options[:default_handler]

    cms_options = options.extract_only!(:label, :instructions)
    dropdown_options = options.extract_only!(:default_handler)
    add_tabindex!(options)
    render_cms_form_partial :template_editor, :method => method, :dropdown_options => dropdown_options, :options => options, :cms_options => cms_options
  end
end