Files

Padrino::Rendering::ClassMethods

Class methods responsible for rendering templates as part of a request.

Public Instance Methods

cache_template_file!(template_file, render_options) click to toggle source

Caches the template file for the given rendering options

@param [String] template_file

The path of the template file.

@param [Array<template_path, content_type, locale>] render_options

# File lib/padrino-core/application/rendering.rb, line 87
def cache_template_file!(template_file, render_options)
  (@_cached_templates ||= {})[render_options] = template_file || []
end
fetch_layout_path(given_layout=nil) click to toggle source

Returns the cached layout path.

@param [Symbol, nil] given_layout

The requested layout.
# File lib/padrino-core/application/rendering.rb, line 97
def fetch_layout_path(given_layout=nil)
  layout_name = given_layout || @layout || :application
  @_cached_layout ||= {}
  cached_layout_path = @_cached_layout[layout_name]
  return cached_layout_path if cached_layout_path
  has_layout_at_root = Dir["#{views}/#{layout_name}.*"].any?
  layout_path = has_layout_at_root ? layout_name.to_sym : File.join('layouts', layout_name.to_s).to_sym
  @_cached_layout[layout_name] = layout_path unless reload_templates?
  layout_path
end
fetch_template_file(render_options) click to toggle source

Returns the cached template file to render for a given url, content_type and locale.

@param [Array<template_path, content_type, locale>] render_options

# File lib/padrino-core/application/rendering.rb, line 75
def fetch_template_file(render_options)
  (@_cached_templates ||= {})[render_options]
end
layout(name=:layout, &block) click to toggle source

Use layout like rails does or if a block given then like sinatra. If used without a block, sets the current layout for the route.

By default, searches in your:

app/views/layouts/application.(haml|erb|xxx) app/views/layout_name.(haml|erb|xxx)

If you define layout :custom then searches for your layouts in app/views/layouts/custom.(haml|erb|xxx) app/views/custom.(haml|erb|xxx)

@param [Symbol] name (:layout)

The layout to use.

@yield []

# File lib/padrino-core/application/rendering.rb, line 65
def layout(name=:layout, &block)
  return super(name, &block) if block_given?
  @layout = name
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.