App-Mowyw

 view release on metacpan or  search on metacpan

script/mowyw  view on Meta::CPAN


=over

=item

C<verbatim> reads the file until it finds an C<endverbatim> tag. It expects a
marker, which must be present at the end tag as well. Everything inbetween
is taken verbatimly, i.e. it is not processed at all. Keywords are not
allowed as markers. Example: 
C<[% verbatim foo %] Some [% non-processed %] markup [% endverbatim foo %]>

=item

C<syntax> uses vim(1) to do syntax hilighting. Expects the name of the
language or configuration as its only argument. Example: `<pre>[%syntax
perl%]print "Hello, world\n";[%endsyntax%]</pre>`. The pseudo-syntax
C<escape> HTML-escapes the string and doesn't to any other syntax
hilighting.

=item

C<for> iterates of a datasource. See section <<datasource,DATA SOURCES>> 
below.

=item

C<ifvar> executes the block only if the variable is defined.
Example: C<[% ifvar title %]<h1>[%readvar title%]</h1>[% endifvar %]>.

=back
   

=head1 MENUES

mowyw has special menu support. To define a menu named C<foo>, create a file
C<source/menu-foo> with the following contents:

   <h2>Your menu title</h2>
   <ul>
       [% item home  <li><a {{class="active"}} href="/">Home</a></li>       %]
       [% item first <li><a {{class="active"}} href="/first">First</a></li> %]
       [% item sec   <li><a {{class="active"}} href="/sec/">First</a> 
           {{
                [% comment this is a sub menu that will only be visible
                    inside the `sec' menu                     %]
                [% item subitem1 <p>More menu markup</p>      %]
                [% item subitem2 <p>Even more menu markup</p> %]
           }}
       </li>   %]
   </ul>

(The menu name is purely for your internal use, it will appear nowhere in the
output)

Now in your index page you can include that menu with the directive 
C<[% menu home %]>. This will produce the menu contents with the markup
stripped, and insde the C<home> all of the contents will appear, the other menu
items only contribute the parts that are B<not> enclosed in double curly
braces.

Menus can ben nested, a nested menu entry can be accessed for example with
C<[% menu sec subitem1 %]>.

It's best to take a look at the examples in the distribution, which should
nicely illustrate the menu mechanism.


=head1 SYNTAX HILIGHTING

Syntax hilighting requires vim (see L<http://www.vim.org/>) and
L<Text::VimColor> to be installed
(otherwise the code is just HTML escaped, not hilighted).

Since you can't tell vim which encoding a source file is in,
non-ASCII-characters might not survive the round trip to vim if the locales
don't fit. On my systems UTF-8 locales worked, everything else didn't. So use
with caution.

=head1 OPTIONS

Currently only two options are supported, C<no-header> and C<no-footer>.
If they are set in a file via C<[% option no-header %]>, the inclusion of
header or footer files will be omitted.


=head1 DATA SOURCES

You can access external data sources by first C<bind>'ing a variable to a
data source, and then iterating with a C<for> loop over that source.

This is best illustrated with a short example.

File C<includes/news.xml>:
        
    <rootTag>
        <item>
            <headline>China buys Google</headline>
            <status>April's fool joke</stoke>
            <date>2007</date>
        </item>
        <item>
            <headline>Perl and Python join forces: Larry Wall and Guido von
            Rossum announce 'parrot'</headline>
            <status>April's fool joke</stoke>
            <date>Very old</date>
        </item>
    </rootTag>

Now you can access the contents of this XML file in your source files:

    [% bind news_variable type:xml file:news.xml root:item %]
    [% comment and iterate over news_variable %]
    [% for i in news_variable %]
        <h2>Breaking news: [% readvar i.headline %]</h2>
        <p>Status: [% readvar i.status %]</p>
    [% endfor %]

Data sources are handled via plugins. Currently XML and DBI are supported.

The XML source is explained by the example above. The only additional option
is 'limit', which can be set to a positive number and which limits the number



( run in 0.692 second using v1.01-cache-2.11-cpan-d8267643d1d )