diff --git a/docs/en.md b/docs/en.md index 39ee564..6671e35 100644 --- a/docs/en.md +++ b/docs/en.md @@ -1265,16 +1265,22 @@ Operating the template system is easy and is based primarily on two methods. One void set(string $name, mixed $value) ``` -Assigns a value to a variable that can be used in views. +Assigns a value or function to a variable that can be used in views. #### Arguments + `name` — variable name -+ `value` — variable value ++ `value` — variable value or anonymous function #### Example ```php +// Assignment of the array $foo = ['bar', 'baz', 'qux']; $this->tpl->set('foo', $foo); + +// Assign an anonymous function +$this->tpl->set('bar', function() { + return ['baz' => 'qux']; +}) ``` diff --git a/docs/pl.md b/docs/pl.md index 0b31989..a34b3b5 100644 --- a/docs/pl.md +++ b/docs/pl.md @@ -1264,16 +1264,22 @@ Obsługa systemu szablonów jest łatwa i opiera się głównie na dwóch metoda void set(string $name, mixed $value) ``` -Przypisuje wartość do zmiennej, którą będzie można się posługiwać w widokach. +Przypisuje wartość lub funkcję do zmiennej, którą będzie można się posługiwać w widokach. #### Argumenty + `name` — nazwa zmiennej -+ `value` — wartość zmiennej ++ `value` — wartość zmiennej lub anonimowa funkcja #### Przykład ```php +// Przypisanie tablicy $foo = ['bar', 'baz', 'qux']; $this->tpl->set('foo', $foo); + +// Przypisanie funkcji anonimowej +$this->tpl->set('bar', function() { + return ['baz' => 'qux']; +}) ```