<!-- 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>Dancer + Bootstrap Examples</h2>
			<h1>Markdown plugin</h1>
		</div>
	</div>
</div>

<div class="row">
	<div class="span12">

	<p>
	<a target="_blank" href="http://en.wikipedia.org/wiki/Markdown">Markdown</a> is a lightweight markup language, originally created by John Gruber and Aaron Swartz allowing people "to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML)
	</p>
	<p>
	A typical use of <strong>markdown</strong> in your Dancer application would be to store markdown-flavored text in a database, and render it to HTML on the fly. This is example what this demo does.
	</p>
	
	<br/>

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

		<li>This HTML tempate is in
                    <a href="[% request.uri_for("/show_file",file => "markdown.tt", example => "Markdown", url => request.uri_for("/markdown") ) %]">
                    <code>./views/examples/markdown.tt</code> <i class="icon-eye-open"></i> </a>.
                </li>
		<li>The markdown text is stored in the <code>$markdown_text</code> variable in the Dancer module.</li>
		<li>The rendering is performed in the template file, using <code>[&#37; USE Markdown &#37;]</code> followed by <code>[&#37; YOUR_VARIABLE | markdown &#37;]</code> commands.</li>
		<li>See <a target="_blank" href="http://search.cpan.org/dist/Template-Plugin-Markdown/">Template::Plugin::Markdown</a> for more details.</li>
	</ul>

	</div>
</div>

<br/>
<br/>

<div class="row">
	<div class="span12">
[%################################
  Markdown example starts here

  NOTE:
   Because we don't require the user to install the Text::Markdown
   and Template::Plugin::Markdown perl modules, it's possible that Markdown
   support is not loaded - So only use the plugin if the Dancer module indicated
   that the modules are loaded.

   In a standard (production) Dancer website, you'll probably require Template::Plugin::Markdown
   to be installed, so this check won't be needed.
#################################%]

[% IF have_text_markdown %]
	[% USE Markdown %]
	<h2>Markdown Text Rendering</h2>
	<br/>
	<div class="well">
		[% text | markdown %]
	</div>
[% ELSE %]


[%## Markdown Perl modules are not installed - show a warning %]
<div class="alert alert-error">
	<button type="button" class="close" data-dismiss="alert">&times;</button> 
	<h2>Oops! - Markdown is not installed on this system</h2>
	To render Markdown text, please install the <a target="_blank" href="http://search.cpan.org/dist/Template-Plugin-Markdown/">Template::Plugin::Markdown</a> (usually by running <code>sudo cpan Template::Plugin::Markdown</code>).
</div>

[% END %]

<br/>

The raw (un-rendered) markdown text looks like this:
<pre>
[% text %]
</pre>


	</div>
</div>


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