Class: Pageflow::WidgetType

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/widget_type.rb

Direct Known Subclasses

BuiltInWidgetType, Null

Defined Under Namespace

Classes: Null

Instance Method Summary collapse

Instance Method Details

#enabled_in_editor?Boolean

Override to return false to hide widget in editor.

Returns:

  • (Boolean)

19
20
21
# File 'lib/pageflow/widget_type.rb', line 19

def enabled_in_editor?
  true
end

#nameObject

Override to return a string in snake_case.

Raises:

  • (NotImplementedError)

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.


24
25
26
# File 'lib/pageflow/widget_type.rb', line 24

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.


30
31
32
# File 'lib/pageflow/widget_type.rb', line 30

def render_head_fragment(template, entry)
  ''
end

#rolesObject

Override to return array of role names.

Raises:

  • (NotImplementedError)

14
15
16
# File 'lib/pageflow/widget_type.rb', line 14

def roles
  raise(NotImplementedError, 'WidgetType subclass needs to define roles method.')
end

#translation_keyObject

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