<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME

    Plate - Fast templating engine with support for embedded Perl

SYNOPSIS

        use Plate;
        
        my $plate = Plate-&gt;new(
            path        =&gt; '/path/to/plate/files/',
            cache_path  =&gt; '/tmp/cache/',
            auto_filter =&gt; 'trim',
        );
        
        $plate-&gt;filter(html =&gt; \&amp;HTML::Escape::escape_html);
        $plate-&gt;filter(trim =&gt; sub { $_[0] =~ s/^\s+|\s+$//gr });
        
        # Render /path/to/plate/files/hello.plate cached as /tmp/cache/hello.pl
        my $output = $plate-&gt;serve('hello');
        print $output;

SUBROUTINES/METHODS

 new

        my $plate = Plate-&gt;new(%options);

    Creates a new Plate engine with the options provided.

    Options (with their defaults) are:

    auto_filter =&gt; 'html'

      The name of the default filter to use for template variables when no
      filter is specified, &lt;% ... %&gt;. The built-in default filter is a very
      basic HTML filter. Set this to undef to disable the default filter.

      To prevent the default filter being used for just a single variable,
      just set the filter to an empty string. Eg: &lt;% $unfiltered |%&gt;

    cache_code =&gt; 1

      If set to a true value, the engine will cache compiled template code
      in memory. This vastly improves performance at the expense of some
      memory.

    cache_path =&gt; undef

      Set this to a directory to store compiled templates on the
      filesystem. If the directory does not exist, it will attempt to
      create it using the umask setting.

    cache_suffix =&gt; '.pl'

      Compiled templates stored on the filesystem will have this suffix
      appended.

    chomp =&gt; 1

      If set to a true value (the default), the final newline in every
      template will be removed.

    encoding =&gt; 'UTF-8'

      Set this to the encoding of your template files.

    keep_undef =&gt; undef

      If set to a false value (the default), then variables and calls that
      return undef are converted to an empty string.

    max_call_depth =&gt; 99

      This sets the maximum call depth to prevent infinite recursion.

    package =&gt; 'Plate::Template'

      The package name that templates are compiled and run in.

    path =&gt; ''

      The path to the templates on the filesystem. An empty string (the
      default) refers to the current directory. If set to undef then the
      filesystem will not be searched, only cached templates will be
      served.

    static =&gt; undef

      If set to a false value (the default), the engine will reload and
      recompile templates whenever files are modified.

      If set to a true value, file modification will not be checked nor
      will templates be reloaded. While this improves performance in
      production, it is not recommended in development.

    suffix =&gt; '.plate'

      The suffix appended to template names when searching on the
      filesystem.

    umask =&gt; 077

      The umask used when creating cache files and directories.

 serve

        my $output = $plate-&gt;serve($template_name, @arguments);

    Renders a template. The @arguments will be passed to the template as
    @_.

 serve_with

        my $output = $plate-&gt;serve_with($content, $template_name, @arguments);

    Renders a template with the provided content.

    The content can be passed in one of three ways. If $content is a string
    then it is the name of a template to serve. If $content is a SCALAR ref
    then it is the contents of a template to be compiled and served.
    $content may also be a CODE ref which should return the content
    directly.

 content

    Used from within a template to return the content passed to that
    template.

 has_content

    Used from within a template to determine if that template was called
    with content.

 filter

        $plate-&gt;filter($filter_name =&gt; sub { ... });

    Add a new filter for use in templates. The subroutine will be given one
    argument (the content to filter) as a string, and must return the
    filtered string.

 var

        $plate-&gt;var('$var' =&gt; \$var);
        $plate-&gt;var('%hash' =&gt; \%hash);
        $plate-&gt;var('@array' =&gt; \@array);
        $plate-&gt;var(func =&gt; \&amp;func);
        $plate-&gt;var(CONST =&gt; 123);

    Define a new local variable to be imported into the templating package
    when compiling and running templates. If the value is not a reference
    it will be a constant in the templating package. To remove a var pass
    undef as the value.

    All templates will have access to these variables, subroutines and
    constants even under use strict.

 define

        $plate-&gt;define($template_name =&gt; $content);

    This will cache a template in memory. The $content is the contents of a
    template (as a string) to be compiled or a CODE ref.

 undefine

        $plate-&gt;undefine;
        $plate-&gt;undefine($template_name);

    This will delete a previously cached template, or all templates if the
    name is undef.

 does_exist

        my $exists = $plate-&gt;does_exist($template_name);

    Returns true if a template by that name is cached or exists on the
    filesystem. No attempt will be made to compile the template.

 can_serve

        my $ok = $plate-&gt;can_serve($template_name);

    Returns true if a template by that name can be served, otherwise it
    sets $@ to the reason for failure.

 set

        $plate-&gt;set(%options);

    Set the options for this Plate engine. Options are the same as those
    for "new".

AUTHOR

    Vernon Lyon &lt;vlyon@cpan.org&gt;

BUGS

    Please report any bugs or feature requests on GitHub issues
    &lt;https://github.com/vlyon/Plate/issues&gt;.

SOURCE

    The source code is hosted on GitHub &lt;https://github.com/vlyon/Plate&gt;.
    Feel free to fork the repository and submit pull requests!

SUPPORT

    You can find documentation for this module with the perldoc command.

        perldoc Plate

    You can also read the documentation online on metacpan
    &lt;https://metacpan.org/pod/Plate&gt;.

COPYRIGHT AND LICENSE

    Copyright (C) 2018, Vernon Lyon.

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

</pre></body></html>