Skip to content

Commit

Permalink
Changed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Jul 26, 2017
1 parent 6af62d1 commit 40b5947
Showing 1 changed file with 52 additions and 53 deletions.
105 changes: 52 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 40b5947

Please sign in to comment.