From 40b59471b3a8f46b94640c81bf666fd80a2154c4 Mon Sep 17 00:00:00 2001 From: Matthias Leuffen Date: Wed, 26 Jul 2017 21:54:26 +0200 Subject: [PATCH] Changed namespace --- README.md | 105 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index d032545..420395e 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,6 @@ use TextTemplate. It's just one class. _TextTemplate uses Phing to build the phar-archives and gzip them. Just execute main-target in build.xml to build your own version_ - - - ## Value injection Use the value Tag @@ -96,58 +93,8 @@ To access array elements or objects use "." to access sub-elements: ``` {= users.0.name} - ``` - - -### Adding Filters - -You can add custom filters or overwrite own filters. - -Adding a new Filter: - -```php -$tt->addFilter ("currency", function ($input) { - return number_format ($input, 2, ",", "."); -}); ``` -Use this filter inside your template - -``` -{= someVariable | currency } -``` - -### Predefined Filters - -| Name | Description | -|----------------|--------------------------------------------| -| raw | Display raw data (skip default escaping) | -| singleLine | Transform Line-breaks to spaces | -| inivalue | like singleLine including addslashes() | -| html | htmlspecialchars() | - - -### Replacing the default-Filter -By default and for security reason all values will be escaped using the "_DEFAULT_"-Filter. (except if -"raw" was selected within the filter section) - -If you, for some reason, want to disable this functionality or change the escape function you can -overwrite the _DEFAULT_-Filter: - -```php -$tt->addFilter ("_DEFAULT_", function ($input) { - return strip_tags ($input); -}); -``` - -or - -```php -$tt->setDefaultFilter("singleLine"); -``` - -This example will replace the htmlspecialchars() escaper by the strip_tags() function. - ## Loops You can insert loops: @@ -201,6 +148,58 @@ Goodbye World {/if} ``` +### Adding Filters + +You can add custom filters or overwrite own filters. + +Adding a new Filter: + +```php +$tt->addFilter ("currency", function ($input) { + return number_format ($input, 2, ",", "."); +}); +``` + +Use this filter inside your template + +``` +{= someVariable | currency } +``` + +### Predefined Filters + +| Name | Description | +|----------------|--------------------------------------------| +| raw | Display raw data (skip default escaping) | +| singleLine | Transform Line-breaks to spaces | +| inivalue | like singleLine including addslashes() | +| html | htmlspecialchars() | + + +### Replacing the default-Filter +By default and for security reason all values will be escaped using the "_DEFAULT_"-Filter. (except if +"raw" was selected within the filter section) + +If you, for some reason, want to disable this functionality or change the escape function you can +overwrite the _DEFAULT_-Filter: + +```php +$tt->addFilter ("_DEFAULT_", function ($input) { + return strip_tags ($input); +}); +``` + +or + +```php +$tt->setDefaultFilter("singleLine"); +``` + +This example will replace the htmlspecialchars() escaper by the strip_tags() function. + + + + ## Debugging the Parameters To see all Parameters passed to the template use: