Sha256: 653b876538a687526fa6543f2620b8b7941eeac95669223ff10c29954dcd496a

Contents?: true

Size: 1012 Bytes

Versions: 5

Compression:

Stored size: 1012 Bytes

Contents

require 'rubygems'
require 'trellis'

include Trellis

module Routing

  class Routing < Application
    home :home
    logger.level = DEBUG
  end

  class Home < Trellis::Page
    template do html { body { text %[this is the home page] }} end
  end

  class RoutedDifferently < Trellis::Page
    route '/whoa'

    template do html { body { text %[whoa!] }} end
  end

  class RoutedDifferentlyWithParams < Trellis::Page
    route '/day_of_the_year/:year/:month/:day'

    def parse_date
      Date.parse("#{@month}/#{@day}/#{@year}")
    end

    def on_select
      self
    end

    template do
      thtml {
        body {
          h2 {
            text %[Date <trellis:value name="page.parse_date"/>]
          }
          text %[is the <trellis:eval expression="Date.parse(month + '/' + day + '/' + year).yday.to_s"/> day of the year]
          br
          text %[<trellis:action_link>Refresh</trellis:action_link>]
        }
      }
    end
  end

  Routing.new.start if __FILE__ == $PROGRAM_NAME
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trellis-0.1.1 examples/routing/source/routing.rb
trellis-0.1.0 examples/routing/source/routing.rb
trellis-0.0.9 examples/routing/source/routing.rb
trellis-0.0.8 examples/routing/source/routing.rb
trellis-0.0.7 examples/routing/source/routing.rb