Module: Ramaze::Helper::Layout::SingletonMethods

### Home Classes Methods

### In Files

- lib/ramaze/helper/layout.rb

### Methods

- #set_layout
- #set_layout_except

### Files

- Gemfile
- Rakefile

### Class/Module Index

Quicksearch

- Ramaze
- Ramaze::App
- Ramaze::Bin
- Ramaze::Bin::Create
- Ramaze::Bin::Runner
- Ramaze::Cache
- Ramaze::Cache::LRU
- Ramaze::Cache::LocalMemCache
- Ramaze::Cache::MemCache
- Ramaze::Cache::Redis
- Ramaze::Cache::Sequel
- Ramaze::Controller
- Ramaze::CoreExtensions
- Ramaze::CoreExtensions::Object
- Ramaze::CoreExtensions::String
- Ramaze::Current
- Ramaze::DefaultController
- Ramaze::Files
- Ramaze::Gestalt
- Ramaze::Helper
- Ramaze::Helper::Auth
- Ramaze::Helper::Bench
- Ramaze::Helper::BlueForm
- Ramaze::Helper::BlueForm::Form
- Ramaze::Helper::CSRF
- Ramaze::Helper::Cache
- Ramaze::Helper::Cache::SingletonMethods
- Ramaze::Helper::Email
- Ramaze::Helper::Erector
- Ramaze::Helper::Flash
- Ramaze::Helper::Formatting
- Ramaze::Helper::Gestalt
- Ramaze::Helper::Gravatar
- Ramaze::Helper::Identity
- Ramaze::Helper::Layout
- Ramaze::Helper::Layout::SingletonMethods
- Ramaze::Helper::Link
- Ramaze::Helper::Localize
- Ramaze::Helper::Localize::Dictionary
- Ramaze::Helper::Localize::Parser
- Ramaze::Helper::Markaby
- Ramaze::Helper::Maruku
- Ramaze::Helper::Paginate
- Ramaze::Helper::Paginate::Paginator
- Ramaze::Helper::Paginate::Paginator::ArrayPager
- Ramaze::Helper::Paginate::Paginator::DataMapperPager
- Ramaze::Helper::Remarkably
- Ramaze::Helper::RequestAccessor
- Ramaze::Helper::SendFile
- Ramaze::Helper::SimpleCaptcha
- Ramaze::Helper::Stack
- Ramaze::Helper::Thread
- Ramaze::Helper::Upload
- Ramaze::Helper::Upload::ClassMethods
- Ramaze::Helper::Upload::UploadedFile
- Ramaze::Helper::UserHelper
- Ramaze::Helper::UserHelper::Wrapper
- Ramaze::Helper::XHTML
- Ramaze::LRUHash
- Ramaze::Logger
- Ramaze::Logger::Informer
- Ramaze::Logger::LogHub
- Ramaze::Logger::Logger
- Ramaze::Logger::RotatingInformer
- Ramaze::Logger::Syslog
- Ramaze::Logging
- Ramaze::Reloader
- Ramaze::Reloader::Hooks
- Ramaze::Reloader::WatchInotify
- Ramaze::Reloader::WatchStat
- Ramaze::Request
- Ramaze::Response
- Ramaze::SpecLogger
- Ramaze::View
- Ramaze::View::Erector
- Ramaze::View::Erubis
- Ramaze::View::Ezamar
- Ramaze::View::Gestalt
- Ramaze::View::Haml
- Ramaze::View::Liquid
- Ramaze::View::Liquid::Tag
- Ramaze::View::Lokar
- Ramaze::View::Mustache
- Ramaze::View::Mustache::RamazeContext
- Ramaze::View::Nagoro
- Ramaze::View::Remarkably
- Ramaze::View::Sass
- Ramaze::View::Slippers
- Ramaze::View::Tagz
- Ramaze::View::Tagz::Methods
- Ramaze::View::Tenjin
- Innate
- Innate::View
- Innate::View::Slim
- Nagoro
- Nagoro::Pipe
- Nagoro::Pipe::RenderPartial
- Bacon
- Bacon::PrettyOutput
- Erector
- Erector::Widget
- Rack
- Rack::RouteExceptions
- Tenjin
- Tenjin::Template
- BlankSlate
- Controller
- MainController
- Object

No matching classes.

# Ramaze::Helper::Layout::SingletonMethods

### Public Instance Methods

set_layout(hash_or_layout) click to toggle source

The set_layout method allows you to specify a number of methods and their layout. This allows you to use layout A for methods 1, 2 and 3 but layout B for method 4.

@example

    # The key is the layout, the value an array of methods
    set_layout 'default' => [:method_1], 'alternative' => [:method_2]

    # We can combine this method with layout()
    layout 'default'
    set_layout 'alternative' => [:method_1]

    # This is also perfectly fine
    set_layout 'default'

@param [String, Symbol, to_hash] hash_or_layout

    In case it's a String or Symbol it will directly be used as the
    layout.
    When setting a Hash this hash should have it's keys set to the
    layouts and it's values to an array of methods that use the
    specific layout. For more information see the examples.

@author Yorick Peterse @author Michael Fellinger @author Pistos @since 2011-04-07

    # File lib/ramaze/helper/layout.rb, line 89
    def set_layout(hash_or_layout)
      @_ramaze_layouts    ||= {}
      @_ramaze_old_layout ||= trait[:layout]

      # Extract the layout to use
      if hash_or_layout.respond_to?(:to_hash)
        # Invert the method/layout hash and save them so they don't get lost
        hash_or_layout.to_hash.each do |layout, layout_methods|
          layout_methods.each do |layout_method|
            @_ramaze_layouts[layout_method.to_s] = layout.to_s
          end
        end

        layout do |path, wish|
          path = path.to_s

          if @_ramaze_layouts.key?(path)
            use_layout = @_ramaze_layouts[path.to_s]
          # Use the old layout
          elsif @_ramaze_old_layout.respond_to?(:call)
            use_layout = @_ramaze_old_layout.call(path, wish)
          else
            use_layout = @_ramaze_old_layout
          end

          use_layout
        end
      else
        layout { |path| hash_or_layout }
      end
    end

set_layout_except(hash_or_layout) click to toggle source

@deprecated because it's not longer useful

    # File lib/ramaze/helper/layout.rb, line 122
    def set_layout_except(hash_or_layout)
      Ramaze.deprecated('set_layout_except', 'set_layout')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.