Template-EmbeddedPerl

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN

Compiles and executes the provided template content with the given arguments. You might
want to enable the cache if you are doing this.

# HELPER FUNCTIONS

The module provides a set of default helper functions that can be used in templates.

- `raw`

    Returns a string as a safe string object without escaping.   Useful if you
    want to return actual HTML to your template but you better be 
    sure that HTML is safe.

        <%= raw '<a href="http://example.com">Example</a>' %>

- `safe`

    Returns a string as a safe html escaped string object that will not be 
    escaped again.

- `safe_concat`

    Like `safe` but for multiple strings.  This will concatenate the strings into
    a single string object that will not be escaped again.

- `html_escape`

    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 JavaScript entities in a string. Useful for making strings safe to use
     in JavaScript.

- `trim`

    Trims leading and trailing whitespace from a string.

# 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.562 second using v1.01-cache-2.11-cpan-71847e10f99 )