Sha256: f5298d785fb24e8915d0de19e4cb4ef1a609cc1e15a937d73fe1e58bc0f1e400

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

module Fuel
  module ApplicationHelper
    Fuel.configuration.helpers.each do |helper|
      include "::#{helper}".constantize
    end

    def markdown(text)
      markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
          :autolink => true, :space_after_headers => true)
      raw markdown.render(text)
    end

    # Can search for named routes directly in the main app, omitting
    # the "main_app." prefix
    def method_missing method, *args, &block
      if main_app_url_helper?(method)
        main_app.send(method, *args)
      else
        super
      end
    end

    def respond_to?(method)
      main_app_url_helper?(method) or super
    end

    private

      def main_app_url_helper?(method)
        (method.to_s.end_with?('_path') or method.to_s.end_with?('_url')) and main_app.respond_to?(method)
      end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fuel-0.3.3 app/helpers/fuel/application_helper.rb
fuel-0.3.2 app/helpers/fuel/application_helper.rb
fuel-0.3.1 app/helpers/fuel/application_helper.rb