Module: Camping::Views

### Home Classes Methods

### In Files

- lib/camping-unabridged.rb

### Included Modules

- Camping::Controllers
- Camping::Helpers

### Files

- CHANGELOG
- COPYING

### Class/Module Index

Quicksearch

- Camping
- Camping::Base
- Camping::Controllers
- Camping::Cookies
- Camping::H
- Camping::Helpers
- Camping::Models
- Camping::Models::Base
- Camping::Reloader
- Camping::Server
- Camping::Server::Options
- Camping::Server::XSendfile
- Camping::Session
- Camping::Views
- Camping::X

No matching classes.

# Camping::Views

Views is an empty module for storing methods which create HTML. The HTML is described using the Markaby language.

## Defining and calling templates

Templates are simply Ruby methods with Markaby inside:

    module Blog::Views
      def index
        p "Welcome to my blog"
      end

      def show
        h1 @post.title
        self << @post.content
      end
    end

In your controllers you just call `render :template_name` which will invoke the template. The views and controllers will share instance variables (as you can see above).

## Using the layout method

If your Views module has a `layout` method defined, it will be called with a block which will insert content from your view:

    module Blog::Views
      def layout
        html do
          head { title "My Blog "}
          body { self << yield }
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.