<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Dev411 Blog: Category templatetoolkit</title>
  <subtitle type="html">John Wang on Technology</subtitle>
  <id>tag:www.dev411.com,2005:Typo</id>
  <generator uri="http://www.typosphere.org" version="4.0">Typo</generator>
  <link href="http://www.dev411.com/blog/xml/atom/category/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.dev411.com/blog/tag/templatetoolkit" rel="alternate" type="text/html"/>
  <updated>2007-06-16T12:30:22-05:00</updated>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:77762545b1dda44d93f114f89f64dfb0</id>
    <published>2006-06-05T20:52:00-05:00</published>
    <updated>2007-06-16T12:30:22-05:00</updated>
    <title type="html">HTML::Prototype - AJAX Without JavaScript</title>
    <link href="http://www.dev411.com/blog/2006/06/05/html-prototype-ajax-without-javascript" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <category term="templatetoolkit" scheme="http://www.dev411.com/blog/tag/templatetoolkit" label="templatetoolkit"/>
    <category term="ajax" scheme="http://www.dev411.com/blog/tag/ajax" label="ajax"/>
    <category term="scriptaculous" scheme="http://www.dev411.com/blog/tag/scriptaculous" label="scriptaculous"/>
    <category term="prototype" scheme="http://www.dev411.com/blog/tag/prototype" label="prototype"/>
    <summary type="html">&lt;p&gt;&lt;a href="http://search.cpan.org/~esskar/HTML-Prototype-1.45/lib/HTML/Prototype.pm"&gt;HTML::Prototype&lt;/a&gt; is by far the most painless way to get started with AJAX that I've found. Simply put, you do not need to know or write any JavaScript! HTML::Prototype is a Perl module on CPAN that wraps the prototype AJAX library and Script.aculo.us effects library with Perl helper methods so you don't need to write a single line of JavaScript to get some great effects. There are also a number of modules that wrap HTML::Prototype for integration with &lt;a href="http://search.cpan.org/~sri/Catalyst-Plugin-Prototype-1.32/lib/Catalyst/Plugin/Prototype.pm"&gt;Catalyst&lt;/a&gt;, &lt;a href="http://search.cpan.org/~ceeshek/CGI-Application-Plugin-HTMLPrototype-0.20/lib/CGI/Application/Plugin/HTMLPrototype.pm"&gt;CGI::Application&lt;/a&gt;, &lt;a href="http://search.cpan.org/~bauerb/Template-Plugin-HTML-Prototype-0.01/lib/Template/Plugin/HTML/Prototype.pm"&gt;Template Toolkit&lt;/a&gt; and others.&lt;/p&gt;

&lt;p&gt;There are a number of convenient methods such as &lt;span class="fix"&gt;link_to_remote()&lt;/span&gt; and &lt;span class="fix"&gt;submit_to_remote()&lt;/span&gt; that create a link and form button to make an AJAX call and populate the innerHTML of a specified DOM element with the response body. Syntactic sugar to be sure as the JS generated by HTML::Prototype is very simple once you look at it, but the beauty is that you never have to.&lt;/p&gt;

&lt;p&gt;To truly appreciate HTML::Prototype you need to use some of Scriptaculous' more advanced widgets such as autocomplete. Sebastian Riedel put together a screencast using Catalyst that demonstrates how easy it is to use. Links to the screencast are available on the Catalyst wiki movies page:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dev.catalyst.perl.org/wiki/Movies"&gt;http://dev.catalyst.perl.org/wiki/Movies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another great thing about having HTML::Prototype generate the JS syntax for you is that you can learn prototype syntax just by View Source. I picked up enough of prototype's JS syntax this way that I haven't looked at the docs yet.&lt;/p&gt;

&lt;p&gt;I've recently removed HTML::Prototype from a project in favor of using &lt;span class="fix"&gt;prototype.js&lt;/span&gt; and &lt;span class="fix"&gt;scriptaculous.js&lt;/span&gt; directly and I'm evaluating the Dojo Toolkit but HTML::Prototype let me get started with very effective, painless AJAX functionality. I used it with Catalyst::Plugin::Prototype and thought 'this is how frameworks make you productive.' Thanks to all the contributors.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://search.cpan.org/~esskar/HTML-Prototype-1.45/lib/HTML/Prototype.pm"&gt;HTML::Prototype&lt;/a&gt; is by far the most painless way to get started with AJAX that I've found. Simply put, you do not need to know or write any JavaScript! HTML::Prototype is a Perl module on CPAN that wraps the prototype AJAX library and Script.aculo.us effects library with Perl helper methods so you don't need to write a single line of JavaScript to get some great effects. There are also a number of modules that wrap HTML::Prototype for integration with &lt;a href="http://search.cpan.org/~sri/Catalyst-Plugin-Prototype-1.32/lib/Catalyst/Plugin/Prototype.pm"&gt;Catalyst&lt;/a&gt;, &lt;a href="http://search.cpan.org/~ceeshek/CGI-Application-Plugin-HTMLPrototype-0.20/lib/CGI/Application/Plugin/HTMLPrototype.pm"&gt;CGI::Application&lt;/a&gt;, &lt;a href="http://search.cpan.org/~bauerb/Template-Plugin-HTML-Prototype-0.01/lib/Template/Plugin/HTML/Prototype.pm"&gt;Template Toolkit&lt;/a&gt; and others.&lt;/p&gt;

&lt;p&gt;There are a number of convenient methods such as &lt;span class="fix"&gt;link_to_remote()&lt;/span&gt; and &lt;span class="fix"&gt;submit_to_remote()&lt;/span&gt; that create a link and form button to make an AJAX call and populate the innerHTML of a specified DOM element with the response body. Syntactic sugar to be sure as the JS generated by HTML::Prototype is very simple once you look at it, but the beauty is that you never have to.&lt;/p&gt;

&lt;p&gt;To truly appreciate HTML::Prototype you need to use some of Scriptaculous' more advanced widgets such as autocomplete. Sebastian Riedel put together a screencast using Catalyst that demonstrates how easy it is to use. Links to the screencast are available on the Catalyst wiki movies page:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dev.catalyst.perl.org/wiki/Movies"&gt;http://dev.catalyst.perl.org/wiki/Movies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another great thing about having HTML::Prototype generate the JS syntax for you is that you can learn prototype syntax just by View Source. I picked up enough of prototype's JS syntax this way that I haven't looked at the docs yet.&lt;/p&gt;

&lt;p&gt;I've recently removed HTML::Prototype from a project in favor of using &lt;span class="fix"&gt;prototype.js&lt;/span&gt; and &lt;span class="fix"&gt;scriptaculous.js&lt;/span&gt; directly and I'm evaluating the Dojo Toolkit but HTML::Prototype let me get started with very effective, painless AJAX functionality. I used it with Catalyst::Plugin::Prototype and thought 'this is how frameworks make you productive.' Thanks to all the contributors.&lt;/p&gt;

</content>
  </entry>
  <entry>
    <author>
      <name>John Wang</name>
    </author>
    <id>urn:uuid:88edca1f2c06f824128fd583fe68d319</id>
    <published>2006-05-31T18:54:00-05:00</published>
    <updated>2007-06-16T12:30:22-05:00</updated>
    <title type="html">Catalyst::View::TT 0.23 - render method</title>
    <link href="http://www.dev411.com/blog/2006/05/31/catalyst-view-tt-0-23-render-method" rel="alternate" type="text/html"/>
    <category term="catalyst" scheme="http://www.dev411.com/blog/tag/catalyst" label="catalyst"/>
    <category term="perl" scheme="http://www.dev411.com/blog/tag/perl" label="perl"/>
    <category term="templatetoolkit" scheme="http://www.dev411.com/blog/tag/templatetoolkit" label="templatetoolkit"/>
    <summary type="html">&lt;p&gt;Catalyst::View::TT 0.23, the Template Toolkit View for the Catalyst MVC framework, was recently released on May 27, 2006 and just in time. It breaks out the render functionality as a separate method from the process method allowing direct rendering of TT templates in addition to handling the overall catalyst response. This is useful when you want to render a template for say an email body or fragments in a JSON response. The render method is accessed as follows:&lt;/p&gt;

&lt;pre&gt;my $output = $c-&gt;view('TT')-&gt;render(
    $c, 'mytemplate.tt', \%args
);&lt;/pre&gt;

&lt;p&gt;Prior to this, Catalyst::Plugin::SubRequest was the recommended way for rendering a TT template when C::V::TT was being used, e.g. the email body example in the SubRequest POD. This method is a kludge because SubRequest is designed to make public action requests, not for just rendering a template. I didn't mind using SubRequest just once to render a TT template for email, however I grew concerned when I starting using it multiple times to render HTML fragments to return via JSON. I was converting more private methods to public actions just so they could be called by SubRequest when I decided this was too kludgy and went to see if I could call TT directly. I went code diving in C::V::TT where I found the render method in 0.23 on search.cpan.org. I had to install 0.23 from the tarball directly since my CPAN shell would only give me 0.22.&lt;/p&gt;

&lt;p&gt;SubRequest also seems to have a problem in that it nukes the Catalyst::Request parameters so $c-&gt;req-&gt;params is no longer populated correctly after a $c-&gt;subreq call. This created strange results without errors that were hard to pinpoint for me. On #catalyst, network_ninja mentioned he got around this problem by copying the params to $c-&gt;req-&gt;parameters and giving that to SubRequest. My solution is to just stop using SubRequest, at least when I only want to render a template.&lt;/p&gt;

&lt;p&gt;Thanks to the Cat team for breaking out render and releasing it just when I went looking for it.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;Catalyst::View::TT 0.23, the Template Toolkit View for the Catalyst MVC framework, was recently released on May 27, 2006 and just in time. It breaks out the render functionality as a separate method from the process method allowing direct rendering of TT templates in addition to handling the overall catalyst response. This is useful when you want to render a template for say an email body or fragments in a JSON response. The render method is accessed as follows:&lt;/p&gt;

&lt;pre&gt;my $output = $c-&gt;view('TT')-&gt;render(
    $c, 'mytemplate.tt', \%args
);&lt;/pre&gt;

&lt;p&gt;Prior to this, Catalyst::Plugin::SubRequest was the recommended way for rendering a TT template when C::V::TT was being used, e.g. the email body example in the SubRequest POD. This method is a kludge because SubRequest is designed to make public action requests, not for just rendering a template. I didn't mind using SubRequest just once to render a TT template for email, however I grew concerned when I starting using it multiple times to render HTML fragments to return via JSON. I was converting more private methods to public actions just so they could be called by SubRequest when I decided this was too kludgy and went to see if I could call TT directly. I went code diving in C::V::TT where I found the render method in 0.23 on search.cpan.org. I had to install 0.23 from the tarball directly since my CPAN shell would only give me 0.22.&lt;/p&gt;

&lt;p&gt;SubRequest also seems to have a problem in that it nukes the Catalyst::Request parameters so $c-&gt;req-&gt;params is no longer populated correctly after a $c-&gt;subreq call. This created strange results without errors that were hard to pinpoint for me. On #catalyst, network_ninja mentioned he got around this problem by copying the params to $c-&gt;req-&gt;parameters and giving that to SubRequest. My solution is to just stop using SubRequest, at least when I only want to render a template.&lt;/p&gt;

&lt;p&gt;Thanks to the Cat team for breaking out render and releasing it just when I went looking for it.&lt;/p&gt;

</content>
  </entry>
</feed>

