App-Followme
view release on metacpan or search on metacpan
are only run on the folder it is run from and subfolders of it. Followme only
looks at the folder it is run from to determine if other files in the folder
need to be updated. So after changing a file, followme should be run from the
directory containing the file.
Templates support the basic control structures in Perl: "for" loops and
"if-else" blocks. Creating output is a two step process. First you generate a
subroutine from one or more templates, then you call the subroutine with your
data to generate the output.
The template format is line oriented. Commands are enclosed in html comments
(<!-- -->). A command may be preceded by white space. If a command is a block
command, it is terminated by the word "end" followed by the command name. For
example, the "for" command is terminated by an "endfor" command and the "if"
command by an "endif" command.
All lines may contain variables. As in Perl, variables are a sigil character
('$' or '@') followed by one or more word characters. For example, `$name` or
`@names`. To indicate a literal character instead of a variable, precede the
sigil with a backslash. When you run the subroutine that this module generates,
you pass it a metadata object. The subroutine replaces variables in the template
with the value in the field built by the metadata object.
If the first non-white characters on a line are the command start string, the
line is interpreted as a command. The command name continues up to the first
white space character. The text following the initial span of white space is the
command argument. The argument continues up to the command end string.
Variables in the template have the same format as ordinary Perl variables,
a string of word characters starting with a sigil character. for example,
$body @files
are examples of variables. Array variable names (variable names starting with
a `@`) may have a suffix that indicates how the array is sorted. You can add
a suffix to a scalar variable (variable names strting with a `$`) but it
will have no effect. The format for the name is:
@data_field[_by_$sort_field][_reversed]
the brackets are not part of the variable name. They are there to indicate that
these sections are optional. Two examples of variables with sort suffixes are
@files_by_size
@all_files_by_mdate_reversed
The second suffix, \_reversed, indicates that the variable is sorted from
largest to smallest instead of the usual format, from smallest to largest.
When used with date fields \_reversed indicates the variable is sorted from
most recent to oldest.
The following commands are supported in templates:
- do
The remainder of the line is interpreted as Perl code.
- for
Expand the text between the "for" and "endfor" commands several times. The
argument to the "for" command should be an expression evaluating to a list. The
code will expand the text in the for block once for each element in the list.
<ul>
<!-- for @files -->
<li><a href="$url">$title</a></li>
<!-- endfor -->
</ul>
- if
The text until the matching `endif` is included only if the expression in the
"if" command is true. If false, the text is skipped.
<div class="column">
<!-- for @files -->
<!-- if $count % 20 == 0 -->
</div>
<div class="column">
<!-- endif -->
$title<br />
<!-- endfor -->
</div>
- else
The "if" and "for" commands can contain an `else`. The text before the "else"
is included if the expression in the enclosing command is true and the
text after the "else" is included if the "if" command is false or the "for"
command does not execute. You can also place an "elsif" command inside a block,
which includes the following text if its expression is true.
# TEMPLATES
Templates are read either from the same directory as the configuration file
containing the name of the module being run or from the \_templates subdirectory
of the top directory of the site. For more information about the use of
templates, see [App::Followme::Template](https://metacpan.org/pod/App%3A%3AFollowme%3A%3ATemplate).
# VARIABLES
Templates contain if commands, for loops and variables. The following variables
are arrays that can be used as arguments to for loops:
- @files
An array of files in a directory. The files in the list are controlled by the
configuration variables extension, exclude, and exclude\_index.
- @all\_files
An array of all files in a directory and its subdirectories. The files are
controlled by the same configuration variables as @files.
- @top\_files
An array of the most recently modified files in a directory and its
subdirectories. The number of files in the array is controlled by configuration
variable list\_length. The files in the list are controlled by the same
configuration variables as used by @files.
- @folders
( run in 0.901 second using v1.01-cache-2.11-cpan-5b529ec07f3 )