Class: BlockEditor::Blocks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/block_editor/blocks/base.rb

Overview

Base for dynamic blocks

Direct Known Subclasses

ContactForm, Reusable

Class Method Summary collapse

Class Method Details

.controllerObject

Frontend controller used to render views



22
23
24
# File 'lib/block_editor/blocks/base.rb', line 22

def self.controller
  BlockEditor.frontend_parent_controller.constantize
end

.default_optionsObject

Default widget options



27
28
29
# File 'lib/block_editor/blocks/base.rb', line 27

def self.default_options
  {}
end

.nameObject

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/block_editor/blocks/base.rb', line 6

def self.name
  raise NotImplementedError, 'Must specify block name'
end

.render(options = {}) ⇒ Object

Render the block



11
12
13
14
15
16
17
18
19
# File 'lib/block_editor/blocks/base.rb', line 11

def self.render(options = {})
  options = options.reverse_merge(default_options.with_indifferent_access)

  controller.render(
    partial: "block_editor/blocks/#{name}/block",
    locals: { options: options },
    layout: false
  )
end