Method: ScrivitoHelper#scrivito_value

Defined in:
app/helpers/scrivito_helper.rb

#scrivito_value(value) ⇒ Object

Note:

Content rendered using this method will not be editable in the Scrivito UI. If you want in-place editing, use #scrivito_tag instead.

Renders an attribute value of a CMS model, taking its type into account.

Links inside html attributes are rendered using the routing of the application. Values from string attributes are escaped. For other attribute types, a simple default representation is rendered.

Examples:

scrivito_value(@obj.title)


226
227
228
229
230
231
232
233
234
235
236
# File 'app/helpers/scrivito_helper.rb', line 226

def scrivito_value(value)
  renderer = Scrivito::AttributeValueRenderer.new(self)

  case value
  when Scrivito::BasicWidget then render(template: value.show_view_path, locals: {widget: value})
  when Scrivito::HtmlString  then renderer.render_as_html(value)
  when String                then renderer.render_as_string(value)
  when Time                  then renderer.render_as_date(value)
  else value
  end
end