Module: Padrino::Rendering::ClassMethods

### Home Classes Methods

### In Files

- lib/padrino-core/application/rendering.rb

### Methods

- #cache_template_file!
- #fetch_layout_path
- #fetch_template_file
- #layout

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Application
- Padrino::ApplicationLoadError
- Padrino::ApplicationSetupError
- Padrino::Cli
- Padrino::Cli::Adapter
- Padrino::Cli::Base
- Padrino::Erubis
- Padrino::Erubis::SafeBufferEnhancer
- Padrino::Erubis::SafeBufferTemplate
- Padrino::Erubis::Template
- Padrino::Filter
- Padrino::Flash
- Padrino::Flash::Helpers
- Padrino::Flash::Storage
- Padrino::Logger
- Padrino::Logger::Colorize
- Padrino::Logger::Extensions
- Padrino::Logger::Rack
- Padrino::Module
- Padrino::Mounter
- Padrino::Mounter::MounterException
- Padrino::Reloader
- Padrino::Reloader::Rack
- Padrino::Rendering
- Padrino::Rendering::ClassMethods
- Padrino::Rendering::InstanceMethods
- Padrino::Rendering::SafeTemplate
- Padrino::Rendering::TemplateNotFound
- Padrino::Router
- Padrino::Routing
- Padrino::Routing::ClassMethods
- Padrino::Routing::InstanceMethods
- Padrino::Routing::Parent
- Padrino::Routing::UnrecognizedException
- Padrino::Server
- Padrino::ShowExceptions
- Padrino::Tasks
- Padrino::Utils
- HttpRouter
- HttpRouter::Node
- HttpRouter::Node::Path
- HttpRouter::Request
- HttpRouter::Route
- Haml
- Haml::Helpers
- Haml::Util
- Sinatra
- Sinatra::Request
- Slim
- Slim::Template
- Tilt
- Tilt::HamlTemplate
- FileSet
- Kernel
- Module
- Object
- ObjectSpace
- PadrinoTasks
- String
- SupportLite

No matching classes.

# 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 112
    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 122
    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 100
    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 90
    def layout(name=:layout, &block)
      return super(name, &block) if block_given?
      @layout = name
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.