App-Dapper
view release on metacpan or search on metacpan
lib/App/Dapper.pm view on Meta::CPAN
elements for your static website. The default configuration file is as
follows:
---
name : My Site
If you want to use a separate source, layout, or output directory, you may
specify it in this file. For instance:
---
name : My Site
source : _source
layout : _layout
output : _output
All of the configurations in this file are available in layout templates,
based on the Liquid template system. For instance, C<name> in the
configuration file may be used in a template as follows:
{{ site.name }}
=item B<_source/index.md>
A sample markdown file is available in the _source directory. Contents:
---
layout: index
title: Welcome
---
Hello world.
There are a few things to note about this file:
=over 4
=item 1. There is a YAML configuration block at the start of the file.
=item 2. The I<layout> configuration specifies which layout to use.
=item 3. The C<index> layout indicates that C<_layout/index.html> should be used.
=item 4. The C<title> configuration is the name of the post/page. It is optional.
=item 5. All of the configurations may be used in the corresponding layout file.
<!-- Example use of "name" in a layout file -->
<h1>{{ page.name }}</h1>
=back
=item B<_layout/index.html>
Layout files are processed using the Liquid template system. The initial layout
file that is given after you run the C<dapper init> command, is this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>{{ page.title }}</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
{{ page.content }}
</body>
</html>
The main content of the text file that is being rendered with this template
is available using C<{{ page.content }}>.
Definitions specified in the C<_config.yml> file can be referenced under the
"site" namespace (e.g. {{ site.name }}. Definitions specified in the YAML
portion of text files can be referenced under the "page" namespace (e.g.
{{ page.title }}.
=item B<_output/index.html>
The output file that is created is a mix of the input file and the layout that
is specified by the input file. For the default site, the following output
file is created:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Hello world.</p>
</body>
</html>
=back
B<Dapper> provides a number of optional command line switches:
=head2 Options
=over 4
=item B<-s>, B<--source>=I<source directory>
Specify the directory containing source files to process. If this command line option is not present, it defaults to "_source".
=item B<-o>, B<--output>=I<output directory>
Specify the directory to place the output files in. If this command line option is not present, it defaults to "_output".
=item B<-l>, B<--layout>=I<layout directory>
Specify the directory containing source files to process. If this command line option is not present, it defaults to "_layout".
=item B<-h>
Get help on available commands and options.
=item B<-v>
Print the version and exit.
=back
=cut
=head1 METHODS
Dapper may be used directly from a script as well. The following methods are available:
=head2 new
Create a new B<Dapper> object. Example:
my $d = App::Dapper->new();
Alternatively, the source dir, output dir, layout dir, and configuration file
may be specified. Example:
my $d = App::Dapper->new("_source", "_output", "_layout", "_config.yml");
After creating a B<Dapper> object, the followin hash elements may be accessed:
use App::Dapper;
( run in 2.673 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )