Skip to content

Commit 2ada887

Browse files
committed
latte 3.0.22
1 parent 0568537 commit 2ada887

File tree

8 files changed

+60
-12
lines changed

8 files changed

+60
-12
lines changed

latte/cs/filters.texy

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ V šablonách můžeme používat funkce, které pomáhají upravit nebo přefor
4444
.[table-latte-filters]
4545
|## Velikost písmen
4646
| `capitalize` | [malá písmena, první písmeno ve slovech velké |#capitalize]
47+
| `firstLower` | [převede první písmeno na malé |#firstLower]
4748
| `firstUpper` | [převede první písmeno na velké |#firstUpper]
4849
| `lower` | [převede na malá písmena |#lower]
4950
| `upper` | [převede na velká písmena |#upper]
@@ -198,7 +199,7 @@ Slova budou začínat velkými písmeny, všechny zbývající znaky budou malá
198199
{='i like LATTE'|capitalize} {* vypíše 'I Like Latte' *}
199200
```
200201

201-
Viz také [#firstUpper], [#lower], [#upper].
202+
Viz také [#firstLower], [#firstUpper], [#lower], [#upper].
202203

203204

204205
checkUrl .[filter]
@@ -324,6 +325,17 @@ Zaokrouhlí číslo dolů na danou přesnost.
324325
Viz také [#ceil], [#round].
325326

326327

328+
firstLower .[filter]{data-version:3.0.22}
329+
-----------------------------------------
330+
Převede první písmeno na malé. Vyžaduje PHP rozšíření `mbstring`.
331+
332+
```latte
333+
{='The Latte'|firstLower} {* vypíše 'the Latte' *}
334+
```
335+
336+
Viz také [#capitalize], [#firstUpper], [#lower], [#upper].
337+
338+
327339
firstUpper .[filter]
328340
--------------------
329341
Převede první písmeno na velká. Vyžaduje PHP rozšíření `mbstring`.
@@ -332,7 +344,7 @@ Převede první písmeno na velká. Vyžaduje PHP rozšíření `mbstring`.
332344
{='the latte'|firstUpper} {* vypíše 'The latte' *}
333345
```
334346

335-
Viz také [#capitalize], [#lower], [#upper].
347+
Viz také [#capitalize], [#firstLower], [#lower], [#upper].
336348

337349

338350
group(string|int|\Closure $by): array .[filter]{data-version:3.0.16}
@@ -490,7 +502,7 @@ Převede řetězec na malá písmena. Vyžaduje PHP rozšíření `mbstring`.
490502
{='LATTE'|lower} {* vypíše 'latte' *}
491503
```
492504

493-
Viz také [#capitalize], [#firstUpper], [#upper].
505+
Viz také [#capitalize], [#firstLower], [#firstUpper], [#upper].
494506

495507

496508
nocheck .[filter]
@@ -855,7 +867,7 @@ Převede řetězec na velká písmena. Vyžaduje PHP rozšíření `mbstring`.
855867
{='latte'|upper} {* vypíše 'LATTE' *}
856868
```
857869

858-
Viz také [#capitalize], [#firstUpper], [#lower].
870+
Viz také [#capitalize], [#firstLower], [#firstUpper], [#lower].
859871

860872

861873
webalize .[filter]

latte/cs/functions.texy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ V šablonách můžeme kromě běžných PHP funkcí používat i tyto další.
1111
| `first` | [vrací první prvek pole nebo znak řetězce |#first]
1212
| `group` | [seskupí data podle různých kritérií |#group]
1313
| `hasBlock` | [zjistí existenci bloku |#hasBlock]
14+
| `hasTemplate`| [zjistí existenci šablony |#hasTemplate]
1415
| `last` | [vrací poslední prvek pole nebo znak řetězce |#last]
1516
| `odd` | [zkontroluje, zda je dané číslo liché |#odd]
1617
| `slice` | [extrahuje část pole nebo řetězce |#slice]
@@ -117,6 +118,15 @@ Zjistí, zda blok uvedeného jména existuje:
117118
Viz také [kontrola existence bloků |template-inheritance#Kontrola existence bloků].
118119

119120

121+
hasTemplate(string $name): bool .[method]{data-version:3.0.22}
122+
--------------------------------------------------------------
123+
Zjistí, zda existuje šablona uvedeného jména:
124+
125+
```latte
126+
{if hasTemplate('foo.latte')} ... {/if}
127+
```
128+
129+
120130
last(string|array $value): mixed .[method]
121131
------------------------------------------
122132
Vrací poslední prvek pole nebo znak řetězce:

latte/cs/loaders.texy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ getContent(string $name): string .[method]
105105
------------------------------------------
106106
Toto je základní metoda loaderu. Jejím úkolem je získat a vrátit úplný zdrojový kód šablony identifikované pomocí `$name` (jak je předáno metodě `$latte->render()` nebo vráceno metodou [#getReferredName()]).
107107

108-
Pokud šablonu nelze najít nebo k ní přistupovat, tato metoda **musí vyhodit výjimku `Latte\RuntimeException`**.
108+
Pokud šablonu nelze najít nebo k ní přistupovat, tato metoda **musí vyhodit výjimku `Latte\TemplateNotFoundException`**.
109109

110110
```php
111111
public function getContent(string $name): string
@@ -169,7 +169,7 @@ class DatabaseLoader implements Latte\Loader
169169
$stmt->execute([$name]);
170170
$content = $stmt->fetchColumn();
171171
if ($content === false) {
172-
throw new Latte\RuntimeException("Template '$name' not found in database.");
172+
throw new Latte\TemplateNotFoundException("Template '$name' not found in database.");
173173
}
174174
return $content;
175175
}

latte/cs/tags.texy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ Název šablony může být jakákoliv výraz v PHP:
629629
{include $ajax ? 'ajax.latte' : 'not-ajax.latte'}
630630
```
631631

632+
Jestli šablona existuje lze ověřit funkcí [`hasTemplate()`|functions#hasTemplate].
633+
632634
Vložený obsah lze upravit pomocí [filtrů |syntax#Filtry]. Následující příklad odebere všechno HTML a upraví velikost písmen:
633635

634636
```latte

latte/en/filters.texy

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ In templates, we can use functions that help modify or reformat data into its fi
4444
.[table-latte-filters]
4545
|## Letter Casing
4646
| `capitalize` | [lowercase, first letter of each word uppercase |#capitalize]
47+
| `firstLower` | [converts the first letter to lower case |#firstLower]
4748
| `firstUpper` | [converts the first letter to uppercase |#firstUpper]
4849
| `lower` | [converts to lowercase |#lower]
4950
| `upper` | [converts to uppercase |#upper]
@@ -198,7 +199,7 @@ Words will start with uppercase letters, all remaining characters will be lowerc
198199
{='i like LATTE'|capitalize} {* outputs 'I Like Latte' *}
199200
```
200201

201-
See also [#firstUpper], [#lower], [#upper].
202+
See also [#firstLower], [#firstUpper], [#lower], [#upper].
202203

203204

204205
checkUrl .[filter]
@@ -324,6 +325,17 @@ Rounds a number down to the given precision.
324325
See also [#ceil], [#round].
325326

326327

328+
firstLower .[filter]{data-version:3.0.22}
329+
-----------------------------------------
330+
Converts the first letter to lower case. Requires PHP extension `mbstring`.
331+
332+
```latte
333+
{='The Latte'|firstLower} {* vypíše 'the Latte' *}
334+
```
335+
336+
See also [#capitalize], [#firstUpper], [#lower], [#upper].
337+
338+
327339
firstUpper .[filter]
328340
--------------------
329341
Converts the first letter to uppercase. Requires the `mbstring` PHP extension.
@@ -332,7 +344,7 @@ Converts the first letter to uppercase. Requires the `mbstring` PHP extension.
332344
{='the latte'|firstUpper} {* outputs 'The latte' *}
333345
```
334346

335-
See also [#capitalize], [#lower], [#upper].
347+
See also [#capitalize], [#firstLower], [#lower], [#upper].
336348

337349

338350
group(string|int|\Closure $by): array .[filter]{data-version:3.0.16}
@@ -490,7 +502,7 @@ Converts a string to lowercase. Requires the `mbstring` PHP extension.
490502
{='LATTE'|lower} {* outputs 'latte' *}
491503
```
492504

493-
See also [#capitalize], [#firstUpper], [#upper].
505+
See also [#capitalize], [#firstLower], [#firstUpper], [#upper].
494506

495507

496508
nocheck .[filter]
@@ -855,7 +867,7 @@ Converts a string to uppercase. Requires the `mbstring` PHP extension.
855867
{='latte'|upper} {* outputs 'LATTE' *}
856868
```
857869

858-
See also [#capitalize], [#firstUpper], [#lower].
870+
See also [#capitalize], [#firstLower], [#firstUpper], [#lower].
859871

860872

861873
webalize .[filter]

latte/en/functions.texy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ In addition to common PHP functions, you can also use these functions in templat
1111
| `first` | [returns the first element of an array or character of a string |#first]
1212
| `group` | [groups data according to various criteria |#group]
1313
| `hasBlock` | [detects the existence of a block |#hasBlock]
14+
| `hasTemplate`| [detects the existence of a template |#hasTemplate]
1415
| `last` | [returns the last element of an array or character of a string |#last]
1516
| `odd` | [checks if the given number is odd |#odd]
1617
| `slice` | [extracts a slice of an array or a string |#slice]
@@ -117,6 +118,15 @@ Checks if a block of the specified name exists:
117118
See also [block existence check |template-inheritance#Checking Block Existence].
118119

119120

121+
hasTemplate(string $name): bool .[method]{data-version:3.0.22}
122+
--------------------------------------------------------------
123+
Determine if a template of the specified name exists:
124+
125+
```latte
126+
{if hasTemplate('foo.latte')} ... {/if}
127+
```
128+
129+
120130
last(string|array $value): mixed .[method]
121131
------------------------------------------
122132
Returns the last element of an array or the last character of a string:

latte/en/loaders.texy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ getContent(string $name): string .[method]
105105
------------------------------------------
106106
This is the core method of the loader. Its task is to retrieve and return the full source code of the template identified by `$name` (as passed to the `$latte->render()` method or returned by the [#getReferredName()] method).
107107

108-
If the template cannot be found or accessed, this method **must throw a `Latte\RuntimeException`**.
108+
If the template cannot be found or accessed, this method **must throw an `Latte\TemplateNotFoundException`**.
109109

110110
```php
111111
public function getContent(string $name): string
@@ -169,7 +169,7 @@ class DatabaseLoader implements Latte\Loader
169169
$stmt->execute([$name]);
170170
$content = $stmt->fetchColumn();
171171
if ($content === false) {
172-
throw new Latte\RuntimeException("Template '$name' not found in database.");
172+
throw new Latte\TemplateNotFoundException("Template '$name' not found in database.");
173173
}
174174
return $content;
175175
}

latte/en/tags.texy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ The template name can be any PHP expression:
629629
{include $ajax ? 'ajax.latte' : 'not-ajax.latte'}
630630
```
631631

632+
If the template exists can be checked by the function [`hasTemplate()` |functions#hasTemplate].
633+
632634
The included content can be modified using [filters |syntax#Filters]. The following example removes all HTML and adjusts the case:
633635

634636
```latte

0 commit comments

Comments
 (0)