Sha256: 6d7165c29de619aa68ad2478640ddcc7c24ea243d820dc01fe0efaba43787354

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require 'rubygems'
require 'ramaze'

class MainController < Ramaze::Controller
  template_root __DIR__/:template
  engine :RedCloth
  layout :layout

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

  def internal(*args)
    @place = :internal
    @args = args
    <<__REDCLOTH__
h1. The <%= @place %> Template for RedCloth

"Home":<%= Rs(:/) %>

Here you can pass some stuff if you like, parameters are just passed like this:<br />
"<%= @place %>/one":<%= Rs(@place, :one) %><br />
"<%= @place %>/two/three":<%= Rs(@place, :two, :three) %><br />
"<%= @place %>/one?foo=bar":<%= Rs(@place, :one, :foo => :bar) %>

The arguments you have passed to this action are:<br />
<% if @args.empty? %>
  none
<% else %>
  <% @args.each do |arg| %>
    <span><%= arg %></span>
  <% end %>
<% end %>

<%= request.params.inspect %>
__REDCLOTH__
  end

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

  def layout
    <<__HTML__
<html>
  <head>
    <title>Template::RedCloth <%= @place %></title>
  </head>
  <body>
#{@content}
  </body>
</html>
__HTML__
  end
end

Ramaze.start

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ramaze-0.3.5 examples/templates/template_redcloth.rb
ramaze-0.3.9.1 examples/templates/template_redcloth.rb
ramaze-0.3.9 examples/templates/template_redcloth.rb