Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Tenjin::Util(3)	      User Contributed Perl Documentation      Tenjin::Util(3)

NAME
       Tenjin::Util - Utility methods for Tenjin.

VERSION
       version 0.070001

SYNOPSIS
	       # 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 &lt;h1&gt;You &amp; Me&lt;/h1&gt;<br />\n&lt;h2&gt;Me &amp; You&lt;/h2&gt;

DESCRIPTION
       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.

METHODS
   expand_tabs(	$str, [$tabwidth] )
       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 $tabwidth was not passed, with	8 spaces.

   escape_xml( $str )
       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.

   unescape_xml( $str )
       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.

   encode_url( $url )
       Receives	a URL and encodes it by	escaping 'non-standard'	characters.

   decode_url( $url )
       Does the	opposite of encode_url().

   checked( $val )
       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.

   selected( $val )
       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.

   disabled( $val )
       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.

   nl2br( $text	)
       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).

   text2html( $text )
       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().

   tagattr( $name, $expr, [$value] )
   tagattrs( %attrs )
   new_cycle( @items )
       Creates a subroutine reference that can be used for cycling through the
       items of	the @items array. 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

INTERNAL(?) METHODS
   _p( $expression )
       Wraps a Perl expression in a customized wrapper which will be processed
       by the Tenjin preprocessor and replaced with the	standard [==
       $expression =].

   _P( $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.

   _decode_params( $s )
SEE ALSO
       Tenjin, Tenjin::Template, Tenjin::Context.

AUTHOR
       The CPAN	version	of Tenjin was forked by	Ido Perlmuter <ido at
       ido50.net> from version 0.0.2 of	the original plTenjin, which is
       developed by Makoto Kuwata at <http://www.kuwata-lab.com/tenjin/>.

       Development of Tenjin is	done with github at
       <http://github.com/ido50/Tenjin>.

LICENSE	AND COPYRIGHT
       Tenjin is licensed under	the MIT	license.

	       Copyright (c) 2007-2010 the aforementioned authors.

	       Permission is hereby granted, free of charge, to	any person obtaining
	       a copy of this software and associated documentation files (the
	       "Software"), to deal in the Software without restriction, including
	       without limitation the rights to	use, copy, modify, merge, publish,
	       distribute, sublicense, and/or sell copies of the Software, and to
	       permit persons to whom the Software is furnished	to do so, subject to
	       the following conditions:

	       The above copyright notice and this permission notice shall be
	       included	in all copies or substantial portions of the Software.

	       THE SOFTWARE IS PROVIDED	"AS IS", WITHOUT WARRANTY OF ANY KIND,
	       EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO	THE WARRANTIES OF
	       MERCHANTABILITY,	FITNESS	FOR A PARTICULAR PURPOSE AND
	       NONINFRINGEMENT.	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
	       LIABLE FOR ANY CLAIM, DAMAGES OR	OTHER LIABILITY, WHETHER IN AN ACTION
	       OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
	       WITH THE	SOFTWARE OR THE	USE OR OTHER DEALINGS IN THE SOFTWARE.

perl v5.24.1			  2011-03-29		       Tenjin::Util(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | METHODS | INTERNAL(?) METHODS | SEE ALSO | AUTHOR | LICENSE AND COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Tenjin::Util&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help