Sha256: a082b2a254f43aa6cba5df2e1e130c34b1ef03652c69f72ebfd940636296bc90

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

#          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'ramaze'

class MainController < Ramaze::Controller
  template_root __DIR__/:template
  engine :Liquid

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

  def liquid_hash(place, *args)
    {
      'header'     => "The #{place} Template for Liquid",
      'link_home'  => A('Home', :href => :/),
      'link_one'   => A("#{place}/one"),
      'link_two'   => A("#{place}/one/two/three"),
      'link_three' => A("#{place}?foo=Bar"),
      'args'       => args,
      'args_empty' => args.empty?,
      'params'     => request.params.inspect
    }
  end


  def internal *args
    @hash = liquid_hash(:internal, *args)
    %q{
<html>
  <head>
    <title>Template::Liquid internal</title>
  </head>
  <body>
  <h1>{{header}}</h1>
    {{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>
      The arguments you have passed to this action are:
      {% if args_empty %}
        none
      {% else %}
        {% for arg in args %}
          <span>{{arg}}</span>
        {% endfor %}
      {% endif %}
    </div>
    <div>
      {{params}}
    </div>
  </body>
</html>
    }
  end

  def external *args
    @hash = liquid_hash(:external, *args)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ramaze-0.2.0 examples/templates/template_liquid.rb
ramaze-0.2.1 examples/templates/template_liquid.rb
ramaze-0.3.0 examples/templates/template_liquid.rb