<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>transfixed but not dead! &#187; Camping</title>
	<atom:link href="http://transfixedbutnotdead.com/tag/camping/feed/" rel="self" type="application/rss+xml" />
	<link>http://transfixedbutnotdead.com</link>
	<description>my ramblings on life, work &#38; anything left in-between</description>
	<lastBuildDate>Fri, 16 Jul 2010 19:57:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='transfixedbutnotdead.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0a317653027efb1ab2bf8adde3dcb067?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>transfixed but not dead! &#187; Camping</title>
		<link>http://transfixedbutnotdead.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://transfixedbutnotdead.com/osd.xml" title="transfixed but not dead!" />
	<atom:link rel='hub' href='http://transfixedbutnotdead.com/?pushpress=hub'/>
		<item>
		<title>Why Squatting?</title>
		<link>http://transfixedbutnotdead.com/2009/08/20/why-squatting/</link>
		<comments>http://transfixedbutnotdead.com/2009/08/20/why-squatting/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 09:02:19 +0000</pubDate>
		<dc:creator>draegtun</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Camping]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Squatting]]></category>

		<guid isPermaLink="false">http://transfixedbutnotdead.com/?p=533</guid>
		<description><![CDATA[Below are two tutorial examples of Camping, a Web Microframework written in Ruby. Alongside them are my two conversions written in Squatting, a Camping-inspired Web Microframework for Perl, written by John Beppu &#160; The Camping Short, Short Example: require 'camping' Camping.goes :HomePage module HomePage::Controllers # The root slash shows the `index' view. class Index &#60; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=transfixedbutnotdead.com&blog=351142&post=533&subd=draegtun&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Below are two tutorial examples of <a href="http://camping.rubyforge.org">Camping</a>, a Web Microframework written in Ruby.</p>
<p>Alongside them are my two conversions written in <a href="http://search.cpan.org/dist/Squatting/">Squatting</a>, a Camping-inspired Web Microframework for Perl, written by <a href="http://search.cpan.org/~beppu/">John Beppu</a></p>
<p>&nbsp;</p>
<p>The Camping Short, Short Example:</p>
<pre class="brush: ruby;">
require 'camping'

Camping.goes :HomePage

module HomePage::Controllers

  # The root slash shows the `index' view.
  class Index &lt; R '/'
    def get
      render :index
    end
  end

  # Any other page name gets sent to the view
  # of the same name.
  #
  #   /index -&gt; Views#index
  #   /sample -&gt; Views#sample
  #
  class Page &lt; R '/(\w+)'
    def get(page_name)
      render page_name
    end
  end

end

module HomePage::Views

  # If you have a `layout' method like this, it
  # will wrap the HTML in the other methods.  The
  # `self &lt;&lt; yield' is where the HTML is inserted.
  def layout
    html do
      title { 'My HomePage' }
      body { self &lt;&lt; yield }
    end
  end

  # The `index' view.  Inside your views, you express
  # the HTML in Ruby.  See http://code.whytheluckystiff.net/markaby/.
  def index
    p 'Hi my name is Charles.'
    p 'Here are some links:'
    ul do
     li { a 'Google', :href =&gt; 'http://google.com' }
     li { a 'A sample page', :href =&gt; '/sample' }
    end
  end

  # The `sample' view.
  def sample
    p 'A sample page'
  end
end
</pre>
<p>The Squatting Short, Short Example:</p>
<pre class="brush: perl;">
use strict;
use warnings;

{
  package ShortShortExample;
  use base 'Squatting';
}

{
  package ShortShortExample::Controllers;
  use Squatting ':controllers';

  our @C = (

    C(
      Index =&gt; [ '/' ],
      get   =&gt; sub {
        my ( $self ) = @_;
        $self-&gt;render( 'index' );
      },
    ),

    C(
      Page =&gt; [ '/(\w+)' ],
      get  =&gt; sub {
        my ( $self, $page_name ) = @_;
        $self-&gt;render( $page_name );
      }
    ),

  );
}

{
  package ShortShortExample::Views;
  use Squatting ':views';
  use HTML::AsSubs;

  our @V = (

    V(  'html',

      layout =&gt; sub {
        my ( $self, $v, @yield ) = @_;
        html(
          title ( 'My HomePage' ),
          body ( @yield ),
        )-&gt;as_HTML;
      },

      index =&gt; sub {
        my ( $self, $v ) = @_;
        return (
          p ( 'Hi my name is Charles.' ),
          p ( 'Here are some links:'   ),
          ul (
            li ( a( { href =&gt; 'http://google.com' },  'Google' ) ),
            li ( a( { href =&gt; '/sample' },  'a sample page'    ) ),
          ),
        );
      },

      sample =&gt; sub {
        my ( $self ) = @_;
        p ( 'A sample page' );
      },

    ),
  );
}

1;
</pre>
<p>&nbsp;</p>
<p>The Camping Tutorial Two:</p>
<pre class="brush: ruby;">
require 'camping'

Camping.goes :Nuts

module Nuts::Controllers
  class Index &lt; R '/'
    def get
      @t = Time.now.to_s
      render :sundial
    end
  end
end

module Nuts::Views
  def layout
    html do
      head do
        title { &quot;Nuts And GORP&quot; }
      end
      body { self &lt;&lt; yield }
    end
  end

  def sundial
    p &quot;The current time is: #{@t}&quot;
  end
end
</pre>
<p>The Squatting Tutorial Two:</p>
<pre class="brush: perl;">
use strict;
use warnings;

{
  package Nuts;
  use base 'Squatting';
}

{
  package Nuts::Controllers;
  use Squatting ':controllers';

  our @C = (
    C(
      Index =&gt; [ '/' ],
      get   =&gt; sub {
        my ( $self ) = @_;
        my $v = $self-&gt;v;
        $v-&gt;{t} = localtime;
        $self-&gt;render( 'sundial' );
      },
    ),
  );
}

{
  package Nuts::Views;
  use Squatting ':views';
  use HTML::AsSubs;

  our @V = (
    V(  'html',

      layout =&gt; sub {
        my ( $self, $v, @yield ) = @_;
        html (
          head ( 'Nuts And GORP' ),
          body ( @yield ),
        )-&gt;as_HTML;
      },

      sundial =&gt; sub {
        my ( $self, $v ) = @_;
        p ( &quot;The current time is: $v-&gt;{t}&quot; );
      },
    ),
  );
}

1;
</pre>
<p>I&#8217;m not going to say much more at this point because I think the code above clearly expresses what&#8217;s going on.  So just enjoy <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>/I3az/</p>
<p>&nbsp;</p>
<p>Postscript:</p>
<p>The two Camping tutorials were written by <a href="http://en.wikipedia.org/wiki/Why_the_lucky_stiff">Why the lucky stiff</a> the author of Camping.  These are no longer available on web because _why was regurgitating them from his own repo/website onto GitHub.   </p>
<p>I wrote the Squatting ports of the tutorial back in October 2008 so luckily I had pulled down these Camping tutorials.  I found that porting _why&#8217;s excellent Camping tutorials were a good way of learning Squatting.</p>
<p>The plan was always to post these on my blog.   In fact I have a long list of stuff to post ranging from just a few scribbles to completed prose.   I&#8217;m just trying to be &#8220;logical&#8221; about the order of these posts!</p>
<p>So why (excuse the pun!) post these now?    The reason will be obvious to most readers&#8230;.  _why&#8217;s strange disappearance from the web overnight.</p>
<p>I not going to conjecture further but I hope all is OK.   So this post is my little ode to _why.</p>
<p>Below are some links on this strange event:</p>
<ul>
<li><a href="http://news.ycombinator.com/item?id=773106">_why is no more (Hacker News)</a></li>
<li><a href="http://news.ycombinator.com/item?id=774384">_why&#8217;s best twitter posts (Hacker News)</a></li>
<li><a href="http://ejohn.org/blog/eulogy-to-_why/">Eulogy to _why (John Resig)</a></li>
<ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/draegtun.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/draegtun.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/draegtun.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/draegtun.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/draegtun.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/draegtun.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/draegtun.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/draegtun.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/draegtun.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/draegtun.wordpress.com/533/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=transfixedbutnotdead.com&blog=351142&post=533&subd=draegtun&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://transfixedbutnotdead.com/2009/08/20/why-squatting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/29cb106071d163d703484e63839d89cb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">draegtun</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Template Toolkit with Squatting</title>
		<link>http://transfixedbutnotdead.com/2008/10/21/using-template-toolkit-with-squatting/</link>
		<comments>http://transfixedbutnotdead.com/2008/10/21/using-template-toolkit-with-squatting/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 12:04:53 +0000</pubDate>
		<dc:creator>draegtun</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Camping]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Squatting]]></category>
		<category><![CDATA[Template Toolkit]]></category>

		<guid isPermaLink="false">http://draegtun.wordpress.com/?p=45</guid>
		<description><![CDATA[Been playing with Squatting recently. Its a Perl Web microframework inspired by Camping. For someone like me who is still converting some old CGI apps to Catalyst then this looks like an interesting alternative. I use Template Toolkit quite a bit so here&#8217;s a boilerplate for using TT with Squatting&#8230;.. use strict; use warnings; { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=transfixedbutnotdead.com&blog=351142&post=45&subd=draegtun&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Been playing with <a href="http://search.cpan.org/dist/Squatting/">Squatting</a> recently.   Its a Perl Web microframework inspired by <a href="http://code.whytheluckystiff.net/camping">Camping</a>.  For someone like me who is still converting some old CGI apps to Catalyst then this looks like an interesting alternative.</p>
<p>I use Template Toolkit quite a bit so here&#8217;s a boilerplate for using TT with Squatting&#8230;..</p>
<pre class="brush: perl;">
use strict;
use warnings;

{
    package App;
    use base 'Squatting';

    BEGIN {
        our %CONFIG = (
            TT =&gt; {
                config   =&gt; { INCLUDE_PATH =&gt; '.' },
                postfix  =&gt; '.tt',
                site_tit =&gt; 'TT loves Squatting!',
            }
        );

    }
}

{
    package App::Controllers;
    use Squatting ':controllers';

    our @C = (

        C(
            Home =&gt; [ '/' ],
            get  =&gt; sub {
                my ( $self )  = @_;
                my $v         = $self-&gt;v;
                $v-&gt;{ tit }   = 'welcome to my homepage';
                $self-&gt;render( 'home' );
            },
        ),

        C(
            Page =&gt; [ '/path/to/page' ],
            get  =&gt; sub {
                my ( $self ) = @_;
                my $v        = $self-&gt;v;
                $v-&gt;{ tit  } = 'here is another page!';
                $v-&gt;{ list } = [ 'one', 'two', 'three' ];
                $self-&gt;render( 'page' );
            },
        ),

    );
}

{
    package App::Views;
    use Squatting ':views';
    use Template;

    our @V = (

        V(
            'html',
            tt =&gt; Template-&gt;new( $App::CONFIG{ TT }-&gt;{ config } ),

            layout =&gt; sub {
                my ( $self, $v, $body ) = @_;
                my $tt = $self-&gt;{ tt };
                $v-&gt;{ site_tit } = $App::CONFIG{ TT }-&gt;{ site_tit };
                $v-&gt;{ body     } = $body;

                my $output;
                $tt-&gt;process( 'layout'. $App::CONFIG{ TT }-&gt;{ postfix }, $v, \$output)
                    or return view_error( $tt-&gt;error );
                return $output;
            },

            _ =&gt; sub {
                my ( $self, $v ) = @_;
                my $tt = $self-&gt;{ tt };
                $v-&gt;{ R } = \&amp;R;

                my $output;
                $tt-&gt;process( $self-&gt;{template} . $App::CONFIG{ TT }-&gt;{ postfix }, $v, \$output)
                    or return view_error( $tt-&gt;error );
                return $output;
            }

        ),
    );

    sub view_error {
        my ( $error ) = shift;
        warn $error;
        return &quot;&lt;pre&gt;&quot; . $error . &quot;&lt;/pre&gt;\n&quot;;   # really need to HTML encode $error here
    }
}

1;
</pre>
<p>And here are the templates&#8230;.</p>
<p>layout.tt</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;
   &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;

&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;[% site_tit %]&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
[% body %]
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>home.tt</p>
<pre class="brush: xml;">
&lt;h1&gt;Hello.. [% tit %]&lt;/h1&gt;

&lt;a href=&quot;[% R('Page') %]&quot;&gt;Have a look here&lt;/a&gt;
</pre>
<p>page.tt</p>
<pre class="brush: xml;">
&lt;h1&gt;Hello again... [% tit %]&lt;/h1&gt;

&lt;p&gt;$v-&gt;{list}...&lt;/p&gt;

&lt;ul&gt;
    [% FOREACH item IN list %]
    &lt;li&gt;[% item %]&lt;/li&gt;
    [% END %]
&lt;/ul&gt;

&lt;a href=&quot;[% R('Home') %]&quot;&gt;back to home&lt;/a&gt;
</pre>
<p>Stash variables in Squatting (ie. variables that can used between controller &amp; the view/template) can be set/get by $self-&gt;v<br />
<em>NB. &#8220;v&#8221; is for variables and shouldn&#8217;t be confused in anyway with &#8220;view&#8221; ;-(</em></p>
<p>Using &#8220;layout[.tt]&#8221; method/template is optional in Squatting (and Camping) so u can drop this and it will just render the view/template only.  The code uses &#8220;layout&#8221; thus home.tt &amp; page.tt renders as [% body %] via layout.tt</p>
<p>R() returns the route used by the specified controller ( for eg. R(&#8216;Page&#8217;) returns &#8220;/path/to/page&#8221; ).  This is quite a handy subroutine to export to TT templates!</p>
<p>So see it working just name above program &#8220;App.pm&#8221; and put in same directory as the template files and just do <code>squatting App</code> and then point your browser to http://localhost:4234/</p>
<p>Hopefully more on Squatting soon.  So if u fancy a bit of fun web programming then give Squatting a go!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/draegtun.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/draegtun.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/draegtun.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/draegtun.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/draegtun.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/draegtun.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/draegtun.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/draegtun.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/draegtun.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/draegtun.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=transfixedbutnotdead.com&blog=351142&post=45&subd=draegtun&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://transfixedbutnotdead.com/2008/10/21/using-template-toolkit-with-squatting/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/29cb106071d163d703484e63839d89cb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">draegtun</media:title>
		</media:content>
	</item>
	</channel>
</rss>