Class TemplateHelpers (namespace Nette\Templates)


Standard template run-time helpers shipped with Nette Framework.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Templates/Filters/TemplateHelpers.php (line 29)
Public Method Summary
TemplateHelpers
Static class - cannot be instantiated.
static string
bytes (int $bytes, [int $precision = 2])
Converts to human readable file size.
static string
date (string|int|DateTime $time, [string $format = "%x"])
Date/time formatting.
static string
escapeCss (string $s)
Escapes string for use inside CSS template.
static string
escapeHtml (mixed $s)
Escapes string for use inside HTML template.
static string
escapeHtmlComment (mixed $s)
Escapes string for use inside HTML comments.
static string
escapeHtmlCss (string $s)
Escapes string for use inside HTML style attribute.
static string
escapeHtmlJs (mixed $s)
Escapes string for use inside HTML JavaScript attribute.
static string
escapeJs (mixed $s)
Escapes string for use inside JavaScript template.
static string
escapeXML (string $s)
Escapes string for use inside XML 1.0 template.
static string
indent (string $s, [int $level = 1], [string $chars = "\t"])
Indents the HTML content from the left.
static int
length (mixed $var)
Returns array of string length.
static callback
loader (string $helper)
Try to load the requested helper.
static string
null (mixed $value)
/dev/null.
static string
replace (string $subject, string $search, [string $replacement = ''])
Performs a search and replace.
static string
replaceRe (string $subject, string $pattern, [string $replacement = ''])
Performs a regular expression search and replace.
static string
strip (string $s)
Replaces all repeated white spaces with a single space.

Method Details

line 35

__construct

public TemplateHelpers __construct ()

Static class - cannot be instantiated.

Output
TemplateHelpers  

line 228

bytes

public static string bytes (int $bytes, [int $precision = 2])

Converts to human readable file size.

Input
int $bytes
int $precision
Output
string  

line 206

date

public static string date (string|int|DateTime $time, [string $format = "%x"])

Date/time formatting.

Input
string|int|DateTime $time
string $format
Output
string  

line 110

escapeCss

public static string escapeCss (string $s)

Escapes string for use inside CSS template.

Input
string $s UTF-8 encoding or 8-bit
Output
string  

line 68

escapeHtml

public static string escapeHtml (mixed $s)

Escapes string for use inside HTML template.

Input
mixed $s UTF-8 encoding or 8-bit
Output
string  

line 83

escapeHtmlComment

public static string escapeHtmlComment (mixed $s)

Escapes string for use inside HTML comments.

Input
mixed $s UTF-8 encoding or 8-bit
Output
string  

line 123

escapeHtmlCss

public static string escapeHtmlCss (string $s)

Escapes string for use inside HTML style attribute.

Input
string $s UTF-8 encoding or 8-bit
Output
string  

line 150

escapeHtmlJs

public static string escapeHtmlJs (mixed $s)

Escapes string for use inside HTML JavaScript attribute.

Input
mixed $s UTF-8 encoding
Output
string  

line 135

escapeJs

public static string escapeJs (mixed $s)

Escapes string for use inside JavaScript template.

Input
mixed $s UTF-8 encoding
Output
string  

line 96

escapeXML

public static string escapeXML (string $s)

Escapes string for use inside XML 1.0 template.

Input
string $s UTF-8 encoding or 8-bit
Output
string  

line 178

indent

public static string indent (string $s, [int $level = 1], [string $chars = "\t"])

Indents the HTML content from the left.

Input
string $s UTF-8 encoding or 8-bit
int $level
string $chars
Output
string  

line 246

length

public static int length (mixed $var)

Returns array of string length.

Input
mixed $var
Output
int  

line 47

loader

public static callback loader (string $helper)

Try to load the requested helper.

Input
string $helper helper name
Output
callback  

line 286

null

public static string null (mixed $value)

/dev/null.

Input
mixed $value
Output
string  

line 260

replace

public static string replace (string $subject, string $search, [string $replacement = ''])

Performs a search and replace.

Input
string $subject
string $search
string $replacement
Output
string  

line 274

replaceRe

public static string replaceRe (string $subject, string $pattern, [string $replacement = ''])

Performs a regular expression search and replace.

Input
string $subject
string $pattern
string $replacement
Output
string  

line 162

strip

public static string strip (string $s)

Replaces all repeated white spaces with a single space.

Input
string $s UTF-8 encoding or 8-bit
Output
string