Sha256: 0be1fcef871aa029b4d07bc2d8d587d18347572b2d0d9994e4849f26f4eb3a77

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

begin
  require 'markaby'
rescue LoadError => e
  raise MissingLibrary, "Markaby could not be loaded (is it installed?): #{e.message}"
end

module Capcode
  class Mab < Markaby::Builder
    include Views
  end
  
  module Helpers
    def render_markaby( f, opts = {} ) #:nodoc:
      f = f.to_s
      layout = opts.delete(:layout)||:layout

      # Update options
      (Capcode.options[:markaby] || {}).merge(opts).each do |k, v|
        Markaby::Builder.set(k, v)
      end
      
      assigns = {}
      self.instance_variables.delete_if {|x| ["@response", "@env", "@request"].include?(x) }.each do |ivar|
        assigns[ivar.gsub( /^@/, "" )] = self.instance_variable_get(ivar)
      end

      __mab = Mab.new(assigns.merge( opts ), self) { 
        if self.respond_to?(layout)
          self.send(layout.to_s) { |*args| 
            # @@__ARGS__ = args
            Capcode::Helpers.args = args
            self.send(f) 
          }
        else
          self.send(f) 
        end
      }
      __mab.to_s  
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capcode-render-markaby-0.1.0 lib/capcode/render/markaby.rb