Module: MarkupAttributesHelper
- Defined in:
- app/helpers/markup_attributes_helper.rb
Overview
The top-level Rails helper which enables consistent rendering of markup attributes.
Rails will make this automatically available in your views; you may need to explicitly include it in other places (like serializers).
This helper exposes a single method: render_markup
Instance Method Summary collapse
-
#render_markup(markup_attribute) ⇒ Object
Given an attribute, returned an HTML-safe, rendered version of the content in that attribute, rendered according to the markup options defined in the model.
Instance Method Details
#render_markup(markup_attribute) ⇒ Object
Given an attribute, returned an HTML-safe, rendered version of the content in that attribute, rendered according to the markup options defined in the model.
If the passed attribute has not been configured as a markup attribute, it will be returned without performing any rendering at all. Th ft ft
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/markup_attributes_helper.rb', line 22 def render_markup(markup_attribute) return markup_attribute if markup_attribute.blank? if markup_attribute.respond_to?(:markup_options) = markup_attribute. html = case [:markup] when :textile require 'redcloth' RedCloth.new(sanitize_using_app(markup_attribute), [:no_span_caps]).to_html else raise "unknown markup attribute type: #{[:markup]}" end cleaned_html = clean_rendered_markup(html, ) cleaned_html.html_safe end end |