Sha256: 2a17b68d1cc05450584e1baa2d8cfdcfb6edea03904f72f6e715451096185698

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module Gumdrop
  
  module Util
    module ViewHelpers
      
      def hidden(&block)
        #no-op
      end

      def urlencode(string)
        require "erb" unless defined? ERB
        ERB::Util.url_encode(string)
      end
      
      def markdown(source)
        eng_class= Gumdrop::Renderer.for 'markdown'
        unless eng_class.nil?
          eng= eng_class.new { source }
          eng.render
        else
          raise StandardError, "Markdown is not available: Include a Markdown engine in your Gemfile!"
        end
      end
      
      def textile(source)
        eng_class= Gumdrop::Renderer.for 'textile'
        unless eng_class.nil?
          eng= eng_class.new { source }
          eng.render
        else
          raise StandardError, "Textile is not available: Include a Textile engine in your Gemfile!"
        end
      end
      
      def config
        site.config
      end

      def data
        site.data
      end

      def gumdrop_version
        ::Gumdrop::VERSION
      end
      
    end
  end
  
  class << self

    def view_helpers(&block)
      Util::ViewHelpers.class_eval &block
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gumdrop-1.1.1 lib/gumdrop/util/view_helpers.rb
gumdrop-1.1.0 lib/gumdrop/util/view_helpers.rb