Skip to content

Commit 7ccb6f6

Browse files
committed
nette/application 3.3.0 [WIP]
1 parent 1422f06 commit 7ccb6f6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

application/cs/templates.texy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ Proměnné do šablony předáváme zápisem do `$this->template`. V šabloně j
120120
$this->template->article = $this->articles->getById($id);
121121
```
122122

123+
Pokud chcete, aby se hodnota určité property automaticky předala do šablony jako proměnná, označte ji atributem `#[TemplateVariable]` a viditelností public: .{data-version:3.3.0}
124+
125+
```php
126+
use Nette\Application\Attributes\TemplateVariable;
127+
128+
class ArticlePresenter extends Nette\Application\UI\Presenter
129+
{
130+
#[TemplateVariable]
131+
public string $siteName = 'Můj blog';
132+
}
133+
```
134+
123135

124136
Výchozí proměnné
125137
----------------

application/en/templates.texy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ Variables are passed to templates by writing them to `$this->template`. They the
120120
$this->template->article = $this->articles->getById($id);
121121
```
122122

123+
To automatically pass a property value to the template as a variable, mark it with the `#[TemplateVariable]` attribute and public visibility: .{data-version:3.3.0}
124+
125+
```php
126+
use Nette\Application\Attributes\TemplateVariable;
127+
128+
class ArticlePresenter extends Nette\Application\UI\Presenter
129+
{
130+
#[TemplateVariable]
131+
public string $siteName = 'My blog';
132+
}
133+
```
134+
123135

124136
Default Variables
125137
-----------------

0 commit comments

Comments
 (0)