Sha256: a1bf98e33caadcd4e0ec61706b3fc9414a6172020a048604152d970e280df8c7

Contents?: true

Size: 835 Bytes

Versions: 16

Compression:

Stored size: 835 Bytes

Contents

# bivouac/helpers/view/base

module BivouacHelpers
  module BaseView
    #   render( :hello, :object => @my_object )
    # is equivalent to
    #   @object = @my_object
    #   hello( )
    def render( partial, options = {} )
      options.each do |k, v|
        self.instance_variable_set( "@#{k.to_s}".to_sym, v )
      end
      self.send( partial.to_sym )
    end
    
    alias_method :partial, :render
    
    # Return the content of a public file as string
    # 
    #   public_to_str( "/stylesheets/autocomplete.css" )
    #   #=> "div.autocomplete {\n position:absolute;\n..."
    def public_to_str( file )
      if file.include? ".."
        return nil
      end
      
      file = ENV['BIVOUAC_ROOT'] + "/public/" + file
      open( file ) do |f|
        data = f.read
      end
      
      return data
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bivouac-0.1.0 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.0.9 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.1 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.3 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.2 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.5 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.4 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.0 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.1.6 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.2 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.1 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.3 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.4 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.4.0 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.3.0 lib/bivouac/helpers/view/goh/base.rb
bivouac-0.2.5 lib/bivouac/helpers/view/goh/base.rb