Class: Markup::Rails::ApplicationViewHelper

Inherits:
Rao::ViewHelper::Base
  • Object
show all
Defined in:
app/view_helpers/markup/rails/application_view_helper.rb

Overview

Example:

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  view_helper Markup::Rails::ApplicationViewHelper, as: :markup_helper
end

Instance Method Summary collapse

Instance Method Details

#to_html(object, method) ⇒ Object

Example:

= markup_helper(self).to_html(post, :body)


13
14
15
16
17
18
# File 'app/view_helpers/markup/rails/application_view_helper.rb', line 13

def to_html(object, method)
  handler = object.send(method, :markup)
  return if handler.nil?
  erb_string = ::ERB.new(object[method.to_sym].to_s, 0).result(binding)
  handler.class.new(erb_string, handler.options).to_html.html_safe
end