Sha256: c024ad6ae0070b2c2e4dbd2a0160a3579a9efa51bc9e763850dfeec46c349790

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

module Ramaze
  module Helper
    # Allows you to use some shortcuts for markaby in your Controller.
    module Markaby
      ##
      # use this inside your controller to directly build Markaby
      # Refer to the Markaby-documentation and testsuite for more examples.
      #
      # @example
      #  mab { h1 "Apples & Oranges"}  #=> "<h1>Apples &amp; Oranges</h1>"
      #  mab { h1 'Apples', :class => 'fruits&floots' }
      #
      def markaby(ivs = {}, helpers = nil, &block)
        builder = ::Markaby::Builder
        builder.extend(Ramaze::Helper::Methods)
        builder.send(:helper, :link)

        iv_hash = {}
        instance_variables.each do |iv|
          key, value = iv.gsub('@', '').to_sym, instance_variable_get(iv)
          iv_hash[key] = value
        end

        builder.new(iv_hash.merge(ivs), helpers, &block).to_s
      end

      alias mab markaby
    end # Markaby
  end # Helper
end # Ramaze

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ramaze-2011.07.25 lib/ramaze/helper/markaby.rb