[%###

This example shows some of the useful Template-Toolkit's plugins from CPAN.
These plugins are not installed by default, so the use will need to install them explicitly.

For the purpose of this demo, we wrap each "USE" with "TRY/CATCH" block, as to not require
the installation of those plugins to run the basic Dancer/Bootstrap website.

###%]

<!-- BootStrap NavBar -->
<div class="navbar">
  <div class="navbar-inner">
    <div class="container">
	<h3><a class="brand" href="[% request.uri_base %]"><img src="images/dancer_man.png"> Perl Dancer</a></h3>
    </div>
  </div>
</div>

<!-- HEADER line -->
<div class="container">

<div class="page-header">
	<div class="row">
		<div class="span12">
			<h2>Template::Toolkit</h2>
			<h1>Template Plugin Examples</h1>
		</div>
	</div>
</div>

<div class="row">
	<div class="span12">
<p>	
This example shows <a target="_blank" href="http://template-toolkit.org/">Template::Toolkit</a>'s plugins (available from <a target="_blank" href="http://search.cpan.org/search?query=Template%3A%3APlugin&mode=module">CPAN</a>).
</p>
<p>
This demo is not Dancer ot bootstrap specific - it just shows how easy it is to use Template::Toolkit plugins.
</p>

	<br/>
	<br/>
	<br/>

	<h3>Code Highlights</h3>
	<ul>
		<li>The minimal Dancer code is in
                    <a href="[% request.uri_for("/show_file",file => "template_plugins.pm", example => "Template_plugins", url => request.uri_for("/template_plugins") ) %]">
                    <code>./lib/examples/template_plugins.pm</code> <i class="icon-eye-open"></i> </a>.
		</li>


		<li>This HTML tempate is in
                    <a href="[% request.uri_for("/show_file",file => "template_plugins.tt", example => "template_plugins", url => request.uri_for("/template_plugins")) %]">
                    <code>./views/examples/template_plugins.tt</code> <i class="icon-eye-open"></i> </a>.
                </li>

		<li>To use <a target="_blank" href="http://search.cpan.org/search?query=Template%3A%3APlugin&mode=module">Template::Plugin::*</a> modules, install them using <code>sudo cpan</code>, then put a <code>[&#37; USE PLUGIN &#37;]</code> in your template file.</li>

		<li>For the purpose of this demo, each <code>[&#37; USE PLUGIN &#37;]</code> is wrapped with a <code>TRY/CATCH</code> block, just in case the module is not installed. In a production website, you will probably have the module installed as a pre-requisite, and so the TRY/CATCH won't be needed
		</li>
	</ul>

	</div>
</div>

<br/>
<div class="row">
	<div class="span12">
	<h2>Template::Plugins::* Modules</h2>
	</div>
</div>
<br/>

[%#############################################
   Template::Plugins examples start here
##############################################%]

<div class="row">
	
[%####### Template::Plugin::Number::Format #####%]
<div class="span4">
	<h3>Number::Format</h3>
	<a target="_blank" href="http://search.cpan.org/search?m=module&q=Template::Plugin::Number::Format">Template::Plugin::Number::Format</a><br/>
	[% TRY %]
		[% USE Number.Format %]
		[% value = 1234567890 %]			
		<ul>
			<li>Unformatted number: [% value %]</li>
			<li>with <strong>format_number()</strong>:
				[% value | format_number %]</li>
			<li>with <strong>format_picture()</strong>:
				[% value | format_picture("USD ###,###,###,###") %]</li>
			<li>with <strong>format_bytes()</strong>:
				[% value | format_bytes %]</li>
			<li>with <strong>format_bytes(precision=>0)</strong>:
				[% value | format_bytes('precision',0) %]</li>
		</ul>		
	[% CATCH %]
		<div class="alert alert-error">
		<strong>Oops</strong><br>
		Template::Plugin::Number::Format failed to load:
		[% error %]
		</div>
	[% END %]
</div>

[%####### Template::Plugin::Image #####%]
<div class="span4">
	<h3>Image</h3>
	<a target="_blank" href="http://search.cpan.org/search?m=module&q=Template::Plugin::Image">Template::Plugin::Image</a><br/>
	[% TRY %]
		[% filename =  settings.appdir _ "/public/images/dancer_man.png" %]
		[% USE img1 = image( filename ) %]
		Image: <img src="[% request.uri_for("/images/dancer_man.png") %]" /><br/>
                width:   [% img1.width %]<br/> 
                height:  [% img1.height %]<br/> 
                type:    [% img1.file_media_type %]<br/> 
	[% CATCH %]
		<div class="alert alert-error">
		<strong>Oops</strong><br>
		Template::Plugin::Image failed to load:<br/>
		[% error %]
		</div>
	[% END %]
</div>


[%####### Template::Plugin::DataRandom #####%]
<div class="span4">
	<h3>DataRandom</h3>
	<a target="_blank" href="http://search.cpan.org/search?m=module&q=Template::Plugin::DataRandom">Template::Plugin::DataRandom</a><br/>
	[% TRY %]
		[% USE r = DataRandom %]
		<ul>
			<li>Random words: [% r.rndwrds('size'=>2).join(",") %]</li>
			<li>Random characters: [% r.rndchrs ( 'set' => 'alpha', 'size' => 5).join(",") %]</li>
			<li>Random time: [% r.rndtime(min => '00:00:00', max => 'now') %]</li>
			<li>Random date: [% r.rnddate(min => '2003-11-08') %]</li>
		</ul>
	[% CATCH %]
		<div class="alert alert-error">
		<strong>Oops</strong><br>
		Template::Plugin::DataRandom failed to load:<br/>
		[% error %]
		</div>
	[% END %]
</div>

</div> <!-- row -->



<div class="row">
[%####### Template::Plugin::xkcd #####%]
[%####### It truly doesn't get any better than this :) ######%]
<div class="span12">
	<h3>xkcd</h3>
	<a target="_blank" href="http://search.cpan.org/search?m=module&q=Template::Plugin::xkcd">Template::Plugin::xkcd</a><br/>
	[% TRY %]
		[% USE xkcd %]
		<h4>Today's XKCD comic</h4>
		[% xkcd.comic %]
	[% CATCH %]
		<div class="alert alert-error">
		<strong>Oops</strong><br>
		Template::Plugin::xkcd failed to load:<br/>
		[% error %]
		</div>
	[% END %]
</div>
</div> <!-- row -->



</div> <!--container -->