Class: Alchemy::ElementsBlockHelper::ElementViewHelper

Inherits:
BlockHelper
  • Object
show all
Defined in:
app/helpers/alchemy/elements_block_helper.rb

Overview

Block-level helper class for element views.

Instance Attribute Summary

Attributes inherited from BlockHelper

#helpers, #opts

Instance Method Summary collapse

Methods inherited from BlockHelper

#element, #initialize

Constructor Details

This class inherits a constructor from Alchemy::ElementsBlockHelper::BlockHelper

Instance Method Details

#content(name) ⇒ Object

Returns one of the element’s contents (ie. essence instances).



42
43
44
# File 'app/helpers/alchemy/elements_block_helper.rb', line 42

def content(name)
  element.content_by_name(name)
end

#essence(name) ⇒ Object

Return’s the given content’s essence.



60
61
62
# File 'app/helpers/alchemy/elements_block_helper.rb', line 60

def essence(name)
  content(name).try(:essence)
end

#has?(name) ⇒ Boolean

Returns true if the given content has been filled by the user.

Returns:

  • (Boolean)


54
55
56
# File 'app/helpers/alchemy/elements_block_helper.rb', line 54

def has?(name)
  element.has_ingredient?(name)
end

#ingredient(name) ⇒ Object

Returns the ingredient of one of the element’s contents.



48
49
50
# File 'app/helpers/alchemy/elements_block_helper.rb', line 48

def ingredient(name)
  element.ingredient(name)
end

#render(name, options = {}, html_options = {}) ⇒ Object

Renders one of the element’s contents.



29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/alchemy/elements_block_helper.rb', line 29

def render(name, options = {}, html_options = {})
  content = element.content_by_name(name)
  return if content.nil?

  helpers.render(content, {
    content: content,
    options: options,
    html_options: html_options,
  })
end