Sha256: a3920894a9e6edd47ec9981293f9f9c5184acd6237c7630dedf27246c15f1a3d

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module RearHelpers
  module InstanceMixin

    def reander *args, &proc
      reander_layout(:layout) { render_slim args, &proc }
    end

    def reander_partial path, *rest
      render_slim_p path_to_rear_templates('%s.slim' % path), *rest
    end
    alias reander_p reander_partial
    
    def reander_layout path, *rest, &proc
      render_slim_l path_to_rear_templates('%s.slim' % path), *rest, &proc
    end
    alias reander_l reander_layout

    def path_to_rear_templates *chunks
      template  = File.join *chunks.map(&:to_s)
      locations = []
      {
        @__rear__templates_path => File.join(app.root, @__rear__templates_path.to_s),
        @__rear__templates_fullpath => @__rear__templates_fullpath,
      }.select {|k,v| k}.each_value do |prefix|
        locations << File.join(prefix, EUtils.class_to_route(self.class.model)) if self.class.respond_to?(:model)
        locations << File.join(prefix, 'shared-templates')
      end
      locations << PATH__TEMPLATES
      locations.each do |p|
        fp = File.join(p, template)
        return explicit_view_path(fp) if File.file?(fp)
      end
      raise ArgumentError, '%s template not found in any of %s paths' % [template,locations*', ']
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rear-0.2.0 lib/rear/helpers/render.rb