Sha256: 333256c99ec927711bdd3e8099f53e1fab12105ba62dd0180e65e7d5cc6659be

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

require 'rubygems'
require 'ramaze'

class MainController < Ramaze::Controller
  view_root __DIR__(:template)
  engine :Amrita2

  def index
    %{ #{A 'Home', :href => :/} | #{A(:internal)} | #{A(:external)} }
  end

  def internal(*args)
    @data = binding
    @place = :internal
    <<__AMRITA2__
<html>
  <head>
    <title>Template::Amrita2 external</title>
  </head>
  <body>
  <h1 am:src="title" />
    <%= link_home %>
    <p>
      Here you can pass some stuff if you like, parameters are just passed like this:<br />
      <%= link_one %><br />
      <%= link_two %><br />
      <%= link_three %>
    </p>
    <<div<
      <<:args<
        <span><%= $_ %></span>
    <%= inspect_parameters %>
  </body>
</html>
__AMRITA2__
  end

  def external(*args)
    @data = binding
    @place = :external
  end

  private

  def title
    "The #{@place} Template for Amrita2"
  end

  def link_home
    A('Home', :href => '/')
  end

  def link_one
    A("/#{@place}/one", :href => Rs(@place, :one))
  end

  def link_two
    A("/#{@place}/one/two/three", :href => Rs(@place, :one, :two, :three))
  end

  def link_three
    A("/#{@place}?foo=bar", :href => Rs(@place, :one, :foo => :bar))
  end

  def inspect_parameters
    request.params.inspect
  end

  def args
    @params.map{|arg| "<span>#{arg}</span>"}.join(' ')
  end
end

Ramaze.start

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
Pistos-ramaze-2008.12 examples/templates/template_amrita2.rb
Pistos-ramaze-2009.01 examples/templates/template_amrita2.rb
Pistos-ramaze-2009.02 examples/templates/template_amrita2.rb
manveru-ramaze-2008.12 examples/templates/template_amrita2.rb
manveru-ramaze-2009.01 examples/templates/template_amrita2.rb
ptomato-ramaze-2009.02.1 examples/templates/template_amrita2.rb
ptomato-ramaze-2009.02 examples/templates/template_amrita2.rb
ramaze-2009.01 examples/templates/template_amrita2.rb
ramaze-2009.02 examples/templates/template_amrita2.rb
ramaze-2009.03 examples/templates/template_amrita2.rb