Sha256: 7b71bc40b142c4460dee77a83c7d5f3aa27031e336e7ba792e30367f4671d680

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'rubygems'
require 'ramaze'

class MainController < Ramaze::Controller
  template_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

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.9 examples/templates/template_amrita2.rb
ramaze-0.3.9.1 examples/templates/template_amrita2.rb