Class: Alchemy::Ingredients::RichtextView

Inherits:
BaseView
  • Object
show all
Defined in:
app/components/alchemy/ingredients/richtext_view.rb

Instance Attribute Summary collapse

Attributes inherited from BaseView

#html_options, #ingredient

Instance Method Summary collapse

Methods inherited from BaseView

#render?

Constructor Details

#initialize(ingredient, plain_text: nil, html_options: {}) ⇒ RichtextView

Returns a new instance of RichtextView.

Parameters:

  • ingredient (Alchemy::Ingredient)
  • plain_text (Boolean) (defaults to: nil)

    (false) Whether to show as plain text or with markup



8
9
10
11
# File 'app/components/alchemy/ingredients/richtext_view.rb', line 8

def initialize(ingredient, plain_text: nil, html_options: {})
  super(ingredient)
  @plain_text = settings_value(:plain_text, value: plain_text, default: false)
end

Instance Attribute Details

#plain_textObject (readonly)

Returns the value of attribute plain_text.



4
5
6
# File 'app/components/alchemy/ingredients/richtext_view.rb', line 4

def plain_text
  @plain_text
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'app/components/alchemy/ingredients/richtext_view.rb', line 13

def call
  if plain_text
    ingredient.stripped_body
  else
    value.to_s.html_safe
  end
end