Class: Pageflow::WidgetType
- Inherits:
-
Object
- Object
- Pageflow::WidgetType
- Defined in:
- lib/pageflow/widget_type.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Null
Instance Method Summary collapse
-
#enabled_in_editor? ⇒ Boolean
Override to return false to hide widget in editor.
-
#enabled_in_preview? ⇒ Boolean
Override to return false to hide widget in entry preview.
-
#insert_point ⇒ Object
Point in DOM where widget should be inserted.
-
#name ⇒ Object
Override to return a string in snake_case.
-
#render(template, entry) ⇒ Object
Override to return html as string.
-
#render_head_fragment(template, entry) ⇒ Object
Override to return html that should be placed in the head element of the page.
-
#render_head_fragment_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render_head_fragment to use the widget configuration.
-
#render_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render to use the widget configuration.
-
#roles ⇒ Object
Override to return array of role names.
-
#translation_key ⇒ Object
Name to display in editor.
Instance Method Details
#enabled_in_editor? ⇒ Boolean
Override to return false to hide widget in editor.
19 20 21 |
# File 'lib/pageflow/widget_type.rb', line 19 def enabled_in_editor? true end |
#enabled_in_preview? ⇒ Boolean
Override to return false to hide widget in entry preview.
24 25 26 |
# File 'lib/pageflow/widget_type.rb', line 24 def enabled_in_preview? true end |
#insert_point ⇒ Object
Point in DOM where widget should be inserted. Possible values are ‘:bottom_of_entry` (default) or `:before_entry`.
32 33 34 |
# File 'lib/pageflow/widget_type.rb', line 32 def insert_point :bottom_of_entry end |
#name ⇒ Object
Override to return a string in snake_case.
9 10 11 |
# File 'lib/pageflow/widget_type.rb', line 9 def name raise(NotImplementedError, 'WidgetType subclass needs to define name method.') end |
#render(template, entry) ⇒ Object
Override to return html as string.
43 44 45 |
# File 'lib/pageflow/widget_type.rb', line 43 def render(template, entry) template.render(File.join('pageflow', name, 'widget'), entry: entry) end |
#render_head_fragment(template, entry) ⇒ Object
Override to return html that should be placed in the head element of the page. Not supported inside the editor.
56 57 58 |
# File 'lib/pageflow/widget_type.rb', line 56 def render_head_fragment(template, entry) '' end |
#render_head_fragment_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render_head_fragment to use the widget configuration. Return html as string that should be placed in the head element of the page.
50 51 52 |
# File 'lib/pageflow/widget_type.rb', line 50 def render_head_fragment_with_configuration(template, entry, _configuration) render_head_fragment(template, entry) end |
#render_with_configuration(template, entry, _configuration) ⇒ Object
Override instead of render to use the widget configuration. Return html as string.
38 39 40 |
# File 'lib/pageflow/widget_type.rb', line 38 def render_with_configuration(template, entry, _configuration) render(template, entry) end |
#roles ⇒ Object
Override to return array of role names.
14 15 16 |
# File 'lib/pageflow/widget_type.rb', line 14 def roles raise(NotImplementedError, 'WidgetType subclass needs to define roles method.') end |
#translation_key ⇒ Object
Name to display in editor.
4 5 6 |
# File 'lib/pageflow/widget_type.rb', line 4 def translation_key "pageflow.#{name}.widget_type_name" end |