Module: Alchemy::EssencesHelper Deprecated
- Included in:
- Admin::EssencesHelper, ElementsHelper
- Defined in:
- app/helpers/alchemy/essences_helper.rb
Overview
Use Rails’ ‘render(content)` method directly instead
This helper contains methods to render the essence
from an Element
Content
.
Essences have two kinds of partials. An editor
and a view
partial.
They both resist in ‘app/views/alchemy/essences’
The partials are suffixed with the type of part.
Example:
For an EssenceText
The view partial is:
_essence_text_view.html.erb
The editor partial is:
_essence_text_editor.html.erb
Usage:
For front end web development you should mostly use the render_essence_view_by_name
helper.
And the render_essence_editor_by_name
helper for Alchemy backend views.
Instance Method Summary collapse
-
#render_essence(content, part = :view, options = {}, html_options = {}) ⇒ Object
deprecated
Deprecated.
Use Rails’ ‘render(content)` method directly instead
-
#render_essence_view(content, options = {}, html_options = {}) ⇒ Object
deprecated
Deprecated.
Use Rails’ ‘render(content)` method directly instead
-
#render_essence_view_by_name(element, name, options = {}, html_options = {}) ⇒ Object
deprecated
Deprecated.
Use Rails’ ‘render(content)` method directly instead
Instance Method Details
#render_essence(content, part = :view, options = {}, html_options = {}) ⇒ Object
Use Rails’ ‘render(content)` method directly instead
Renders the Esssence
partial for given Content
.
The helper renders the view partial as default.
Pass :editor
as second argument to render the editor partial
Options:
You can pass a options Hash to each type of essence partial as third argument.
This Hash is available as options
local variable.
for_view: {}
for_editor: {}
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/alchemy/essences_helper.rb', line 75 def render_essence(content, part = :view, = {}, = {}) = {for_view: {}, for_editor: {}}.update() if content.nil? return part == :view ? "" : warning('Content is nil', Alchemy.t(:content_not_found)) elsif content.essence.nil? return part == :view ? "" : warning('Essence is nil', Alchemy.t(:content_essence_not_found)) end if part == :view render content, { content: content, options: [:for_view], html_options: } else render "alchemy/essences/#{content.essence_partial_name}_editor", { content: content, options: , html_options: } end end |
#render_essence_view(content, options = {}, html_options = {}) ⇒ Object
Use Rails’ ‘render(content)` method directly instead
Renders the Esssence
view partial for given Content
.
Options:
:size => "111x93" # Used by EssencePicture to resize the image to that size. [Default nil]
:date_format => "Am %d. %m. %Y, um %H:%Mh" # Especially for EssenceDate. See Rubys Date.strftime for date formatting options. [Default nil]
:show_caption => false # Pass Boolean to show/hide the caption of an EssencePicture. [Default true]
:disable_link => true # You can surpress the link of an EssencePicture. Default false
109 110 111 112 113 114 115 |
# File 'app/helpers/alchemy/essences_helper.rb', line 109 def render_essence_view(content, = {}, = {}) render content, { content: content, options: , html_options: } end |
#render_essence_view_by_name(element, name, options = {}, html_options = {}) ⇒ Object
Use Rails’ ‘render(content)` method directly instead
Renders the Essence
view partial from Element
by name.
Pass the name of the Content
from Element
as second argument.
Example:
This renders the Content
named “intro” from element.
<%= render_essence_view_by_name(element, "intro") %>
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/alchemy/essences_helper.rb', line 43 def render_essence_view_by_name(element, name, = {}, = {}) if element.blank? warning('Element is nil') && return end content = element.content_by_name(name) return if content.nil? render content, { content: content, options: , html_options: } end |