eucalypt
>= 0.9.0
>= 0.9.0
  • eucalypt
  • Installation
  • CLI
    • Core
      • Init
      • Launch
      • Console
      • Test
      • Version
      • Rake
      • Help (-H)
    • Generate
      • Controller
      • Helper
      • Model
      • Scaffold
    • Destroy
      • Controller
      • Helper
      • Model
      • Scaffold
    • Blog
      • Setup
      • Article
        • List
        • Generate
        • Destroy
        • Edit
          • Urltitle
          • Datetime
    • Migration
      • Blank
      • Types
      • Create
        • Table
      • Add
        • Index
        • Column
      • Drop
        • Table
        • Index
        • Column
      • Rename
        • Table
        • Index
        • Column
      • Change
        • Column
  • Features
    • Controllers
    • Helpers
    • Views
      • Layouts
      • Partials
    • Static data
    • Core application file
    • Configuration
      • Logging
      • Asset pipeline
        • Manifest asset files
      • Initializers
      • Database
    • Manifest accessor
    • Application path helpers
    • Blog environment
      • Articles
    • Rendering static files
    • Maintenance mode
Powered by GitBook
On this page
  • Location
  • Rendering
  1. Features

Views

PreviousHelpersNextLayouts

Last updated 6 years ago

Location

The view files are located in the app/views directory.

Rendering

Eucalypt looks for view files relative to the app/views directory by default (though you can change this in the ).

Views directly inside directory

If your views folder structure is like the following:

views
├── partials
├── layouts
├── index.erb
└── 404.erb

Then you can render the pages index.erb and 404.erb in the following way:

app/controllers/main_controller.rb
class MainController < ApplicationController

  helpers MainHelper if defined? MainHelper
  
  get '/' do
    erb :index
  end
  
  error Sinatra::NotFound do
    erb :"404"
  end 
end

Views inside sub-directories

If your views folder structure is like the following (with some views located within sub-directories):

views
├── partials
├── layouts
├── pages
│   ├── index.erb
│   └── about.erb
└── 404.erb

Then you can render the pages index.erb and 404.erb in the following way (note the specification of the full path relative to app/views for rendering the index page):

app/controllers/main_controller.rb
class MainController < ApplicationController
  helpers MainHelper if defined? MainHelper
  
  get '/' do
    erb :"pages/index"
  end
  
  error Sinatra::NotFound do
    erb :"404"
  end 
end
core application file