Template-EmbeddedPerl

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN


    Escapes HTML entities in a string.  This differs for `safe` in that it will
    just do the escaping and not wrap the string in a safe string object.

- `url_encode`

    Encodes a string for use in a URL.

- `escape_javascript`

    Escapes a value for use inside a JavaScript string, including preventing a closing
    `script` tag from terminating an enclosing HTML script element. This is not a general
    JavaScript sanitizer; use a context-appropriate sanitizer for untrusted code.

- `trim`

    Trims leading and trailing whitespace from a string.

- `partial`

    `partial $identifier, %args` renders an untyped template immediately. Its
    rendered result is safe and is not escaped a second time.

- `layout`

    `layout $identifier, %args` registers an untyped layout around the current
    output. The first declared layout is outermost.

- `yield`

    `yield` returns the current body; `yield $name` returns named content.

- `content_for`, `content_replace`, `has_content`

    Capture, replace, and test named content blocks in the current render frame.

- `view`

    `view $object` renders a preconstructed child; `view $logical_name, %args`
    resolves its class through `view_namespace` and calls `$class->new(%args)`,
    or `view_factory` when configured. A final coderef is a wrapper body; inside
    it `$self` remains the caller and the callback argument is the new wrapper.

# ERROR HANDLING

If an error occurs during template compilation or rendering, the module will
throw an exception with a detailed error message. The error message includes
the source of the template, the line number, and the surrounding lines of the
template to help with debugging.  Example:

Can't locate object method "input" at /path/to/templates/hello.yat line 4.

    3:     <%= label('first_name') %>
    4:     <%= input('first_name') %>
    5:     <%= errors('last_name') %>

# ENVIRONMENT VARIABLES

The module respects the following environment variables: 

- `DEBUG_TEMPLATE_EMBEDDED_PERL`

    Set this to a true value to print the compiled template code to the console. Useful
    when trying to debug difficult compilation issues, especially given this is early
    access code and you might run into bugs.

# REPORTING BUGS & GETTING HELP

If you find a bug, please report it on the GitHub issue tracker at
[https://github.com/jjn1056/Template-EmbeddedPerl/issues](https://github.com/jjn1056/Template-EmbeddedPerl/issues).  The bug tracker is
the easiest way to get help with this module from me but I'm also on irc.perl.org
under `jnap`.

# DEDICATION

This module is dedicated to the memory of my dog Bear who passed away on 17 August 2024.
He was a good companion and I miss him.

If this module is useful to you please consider donating to your local animal shelter
or rescue organization.

# AUTHOR

John Napiorkowski, `<jjnapiork@cpan.org>`

# LICENSE AND COPYRIGHT

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

# POD ERRORS

Hey! **The above document had some coding errors, which are explained below:**

- Around line 765:

    You forgot a '=back' before '=head2'



( run in 0.623 second using v1.01-cache-2.11-cpan-0b58ddf2af1 )