17 May 2016 19:56:02 UTC
- Distribution: Tenjin
- Module version: 1.000001
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (0)
- Testers (863 / 11 / 0)
- KwaliteeBus factor: 0
- 65.54% Coverage
- License: mit
- Perl: v5.8.0
- Download (26.61KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:
- INTERNAL(?) METHODS
- SEE ALSO
- AUTHOR, LICENSE AND COPYRIGHT
Tenjin::Util - Utility methods for Tenjin.
# in your templates: # encode a URL [== encode_url('http://www.google.com/search?q=tenjin&ie=utf-8&oe=utf-8&aq=t') =] # returns http%3A//www.google.com/search%3Fq%3Dtenjin%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt # escape a string of lines of HTML code <?pl my $string = '<h1>You & Me</h1>\n<h2>Me & You</h2>'; ?> [== text2html($string) =] # returns <h1>You & Me</h1><br />\n<h2>Me & You</h2>
This module provides a few utility functions which can be used in your templates for your convenience. These include functions to (un)escape and (en/de)code URLs.
Receives a string that might contain tabs in it, and replaces those tabs with spaces, each tab with the number of spaces defined by
$tabwidth, or, if
$tabwidthwas not passed, with 8 spaces.
Receives a string of XML (or (x)HTML) code and converts the characters <>&\' to HTML entities. This is the method that is invoked when you use [= $expression =] in your templates.
Receives a string of escaped XML (or (x)HTML) code (for example, a string that was escaped with the escape_xml() function, and 'unescapes' all HTML entities back to their actual characters.
Receives a URL and encodes it by escaping 'non-standard' characters.
Does the opposite of encode_url().
Receives a value of some sort, and if it is a true value, returns the string ' checked="checked"' which can be appended to HTML checkboxes.
Receives a value of some sort, and if it is a true value, returns the string ' selected="selected"' which can be used in an option in an HTML select box.
Receives a value of some sort, and if it is a true value, returns the string ' disabled="disabled"' which can be used in an HTML input.
Receives a string of text containing lines delimited by newline characters (\n, or possibly \r\n) and appends an HTML line break (<br />) to every line (the newline character is left untouched).
Receives a string of text containing lines delimited by newline characters, and possibly some XML (or (x)HTML) code, escapes that code with escape_xml() and then appends an HTML line break to every line with nl2br().
Creates a subroutine reference that can be used for cycling through the items of the
@itemsarray. So, for example, you can:
my $cycle = new_cycle(qw/red green blue/); print $cycle->(); # prints 'red' print $cycle->(); # prints 'green' print $cycle->(); # prints 'blue' print $cycle->(); # prints 'red' again
Wraps a Perl expression in a customized wrapper which will be processed by the Tenjin preprocessor and replaced with the standard [== $expression =].
Wrap a Perl expression in a customized wrapper which will be processed by the Tenjin preprocessor and replaced with the standard [= $expression =], which means the expression will be escaped.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|