Skip to content

Commit

Permalink
latte 3.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 17, 2024
1 parent 2ca8ea5 commit 50f27b8
Show file tree
Hide file tree
Showing 36 changed files with 638 additions and 37 deletions.
22 changes: 20 additions & 2 deletions latte/bg/creating-extension.texy
Expand Up @@ -307,7 +307,7 @@ class ForeachNode extends StatementNode
// функция за парсиране, която засега просто създава възел
public static function create(Latte\Compiler\Tag $tag): self
{
$node = new self;
$node = $tag->node = new self;
return $node;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ class ForeachNode extends StatementNode
public static function create(Latte\Compiler\Tag $tag): self
{
$tag->expectArguments();
$node = new self;
$node = $tag->node = new self;
$node->expression = $tag->parser->parseExpression();
$tag->parser->stream->consume('as');
$node->value = $parser->parseExpression();
Expand Down Expand Up @@ -486,6 +486,24 @@ public function &getIterator(): \Generator
```


AuxiliaryNode
-------------

Ако създавате нов таг за Latte, препоръчително е да създадете за него специален клас възел, който ще го представя в дървото AST (вж. класа `ForeachNode` в примера по-горе). В някои случаи може да ви бъде полезен тривиалният помощен клас [AuxiliaryNode |api:Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode], който ви позволява да предадете тялото на метода `print()` и списъка на възлите, направени достъпни от метода `getIterator()`, като параметри на конструктора:

```php
// Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode
// or Latte\Compiler\Nodes\AuxiliaryNode

$node = new AuxiliaryNode(
// body of the print() method:
fn(PrintContext $context, $argNode) => $context->format('myFunc(%node)', $argNode),
// nodes accessed via getIterator() and also passed into the print() method:
[$argNode],
);
```


Компилаторът предава .[#toc-compiler-passes]
============================================

Expand Down
15 changes: 15 additions & 0 deletions latte/bg/tags.texy
Expand Up @@ -16,6 +16,7 @@
| `{ifset}`... `{elseifset}`... `{/ifset}` | [условие ifset |#ifset-elseifset]
| `{ifchanged}`... `{/ifchanged}` | [проверка за промени |#ifchanged]
| `{switch}` `{case}` `{default}` `{/switch}` | [състояние на превключване |#switch-case-default]
| `n:else` | [алтернативно съдържание за условията |#n:else]

.[table-latte-tags language-latte]
|## Цикли
Expand Down Expand Up @@ -246,6 +247,20 @@ Age: {date('Y') - $birth}<br>
Страхотно.


`n:else` .{data-version:3.0.11}
-------------------------------

Ако запишете условието `{if} ... {/if}` под формата на [n:атрибут |syntax#n:attributes], имате възможност да посочите алтернативен клон, като използвате `n:else`:

```latte
<strong n:if="$count > 0">In stock {$count} items</strong>

<em n:else>not available</em>
```

Атрибутът `n:else` може да се използва и в комбинация с [`n:ifset` |#ifset-elseifset], [`n:foreach` |#foreach], [`n:try` |#try], [`n:ifcontent` |#n:ifcontent], и [`n:ifchanged` |#ifchanged].


`{/if $cond}`
-------------

Expand Down
20 changes: 20 additions & 0 deletions latte/cs/cookbook/migration-from-latte2.texy
Expand Up @@ -128,6 +128,26 @@ $latte->addExtension(new Nette\Bridges\CacheLatte\CacheExtension($cacheStorage))
```


Tracy
-----

Panel pro Tracy se nyní aktivuje také jako rozšíření.

Starý kód pro Latte 2:

```php
$latte = new Latte\Engine;
Latte\Bridges\Tracy\LattePanel::initialize($latte);
```

Nový kód pro Latte 3:

```php
$latte = new Latte\Engine;
$latte->addExtension(new Latte\Bridges\Tracy\TracyExtension);
```


Překlady
--------

Expand Down
24 changes: 21 additions & 3 deletions latte/cs/creating-extension.texy
Expand Up @@ -307,7 +307,7 @@ class ForeachNode extends StatementNode
// parsovací funkce, která zatím pouze vytváří uzel
public static function create(Latte\Compiler\Tag $tag): self
{
$node = new self;
$node = $tag->node = new self;
return $node;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ class ForeachNode extends StatementNode
public static function create(Latte\Compiler\Tag $tag): self
{
$tag->expectArguments();
$node = new self;
$node = $tag->node = new self;
$node->expression = $tag->parser->parseExpression();
$tag->parser->stream->consume('as');
$node->value = $parser->parseExpression();
Expand Down Expand Up @@ -406,7 +406,7 @@ public static function create(Latte\Compiler\Tag $tag): \Generator
}
```

Vrácením uzlu je parsování tagu dokončeno.
Vrácením uzlu `$node` je parsování tagu dokončeno.


Generování PHP kódu
Expand Down Expand Up @@ -486,6 +486,24 @@ public function &getIterator(): \Generator
```


AuxiliaryNode
-------------

Pokud vytváříte nový tag pro Latte, je žádoucí, abyste pro něj vytvořili vlastní třídu uzlu, která jej bude reprezentovat v AST stromu (viz třída `ForeachNode` v příkladu výše). V některých případech se vám může hodit pomocná triviální třída uzlu [AuxiliaryNode|api:Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode], které tělo metody `print()` a seznam uzlů, které zpřístupňuje metoda `getIterator()`, předáme jako parametry konstruktoru:

```php
// Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode
// or Latte\Compiler\Nodes\AuxiliaryNode

$node = new AuxiliaryNode(
// tělo metody print():
fn(PrintContext $context, $argNode) => $context->format('myFunc(%node)', $argNode),
// uzly zpřístupnění přes getIterator() a také předané do metody print():
[$argNode],
);
```


Průchody kompilátoru
====================

Expand Down
17 changes: 16 additions & 1 deletion latte/cs/tags.texy
Expand Up @@ -16,6 +16,7 @@ Přehled a popis všech tagů (neboli značek či maker) šablonovacího systém
| `{ifset}` … `{elseifset}` … `{/ifset}` | [podmínka ifset|#ifset-elseifset]
| `{ifchanged}` … `{/ifchanged}` | [test jestli došlo ke změně |#ifchanged]
| `{switch}` `{case}` `{default}` `{/switch}` | [podmínka switch|#switch-case-default]
| `n:else` | [alternativní obsah pro podmínky |#n:else]

.[table-latte-tags language-latte]
|## Cykly
Expand Down Expand Up @@ -89,7 +90,7 @@ Přehled a popis všech tagů (neboli značek či maker) šablonovacího systém
| `n:class` | [dynamický zápis HTML atributu class |#n:class]
| `n:attr` | [dynamický zápis jakýchkoliv HTML atributů |#n:attr]
| `n:tag` | [dynamický zápis jména HTML elementu |#n:tag]
| `n:ifcontent` | [Vynechá prázdný HTML tag |#n:ifcontent]
| `n:ifcontent` | [vynechá prázdný HTML tag |#n:ifcontent]

.[table-latte-tags language-latte]
|## Dostupné pouze v Nette Frameworku
Expand Down Expand Up @@ -246,6 +247,20 @@ Víte, že k n:atributům můžete připojit prefix `tag-`? Pak se bude podmínk
Boží.


`n:else` .{data-version:3.0.11}
-------------------------------

Pokud podmínku `{if} ... {/if}` zapíšete v podobě [n:attributu|syntax#n:atributy], máte možnost uvést i alternativní větev pomocí `n:else`:

```latte
<strong n:if="$count > 0">Skladem {$count} kusů</strong>

<em n:else>není dostupné</em>
```

Atribut `n:else` použít také ve dvojici s [`n:ifset` |#ifset-elseifset], [`n:foreach` |#foreach], [`n:try` |#try], [`n:ifcontent` |#n:ifcontent] a [`n:ifchanged` |#ifchanged].


`{/if $cond}`
-------------

Expand Down
22 changes: 20 additions & 2 deletions latte/de/creating-extension.texy
Expand Up @@ -307,7 +307,7 @@ class ForeachNode extends StatementNode
// eine Parsing-Funktion, die vorerst nur einen Knoten erstellt
public static function create(Latte\Compiler\Tag $tag): self
{
$node = new self;
$node = $tag->node = new self;
return $node;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ class ForeachNode extends StatementNode
public static function create(Latte\Compiler\Tag $tag): self
{
$tag->expectArguments();
$node = new self;
$node = $tag->node = new self;
$node->expression = $tag->parser->parseExpression();
$tag->parser->stream->consume('as');
$node->value = $parser->parseExpression();
Expand Down Expand Up @@ -486,6 +486,24 @@ public function &getIterator(): \Generator
```


AuxiliaryNode
-------------

Wenn Sie ein neues Tag für Latte erstellen, ist es ratsam, eine eigene Knotenklasse dafür zu erstellen, die es im AST-Baum repräsentiert (siehe die Klasse `ForeachNode` im obigen Beispiel). In einigen Fällen kann die triviale Hilfsknotenklasse [AuxiliaryNode |api:Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode] nützlich sein, die es Ihnen ermöglicht, den Körper der Methode `print()` und die Liste der Knoten, die durch die Methode `getIterator()` zugänglich gemacht werden, als Konstruktorparameter zu übergeben:

```php
// Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode
// or Latte\Compiler\Nodes\AuxiliaryNode

$node = new AuxiliaryNode(
// body of the print() method:
fn(PrintContext $context, $argNode) => $context->format('myFunc(%node)', $argNode),
// nodes accessed via getIterator() and also passed into the print() method:
[$argNode],
);
```


Compiler übergibt .[#toc-compiler-passes]
=========================================

Expand Down
15 changes: 15 additions & 0 deletions latte/de/tags.texy
Expand Up @@ -16,6 +16,7 @@ Zusammenfassung und Beschreibung aller in Latte integrierten Tags.
| `{ifset}`... `{elseifset}`... `{/ifset}` | [Bedingung ifset |#ifset-elseifset]
| `{ifchanged}`... `{/ifchanged}` | [Test, ob eine Änderung stattgefunden hat |#ifchanged]
| `{switch}` `{case}` `{default}` `{/switch}` | [Bedingung switch |#switch-case-default]
| `n:else` | [alternative Inhalte für Bedingungen |#n:else]

.[table-latte-tags language-latte]
|## Schleifen
Expand Down Expand Up @@ -246,6 +247,20 @@ Wussten Sie, dass Sie das Präfix `tag-` zu n:Attributen hinzufügen können? Da
Schön.


`n:else` .{data-version:3.0.11}
-------------------------------

Wenn Sie die Bedingung `{if} ... {/if}` in Form eines [n:-Attributs |syntax#n:attributes] schreiben, haben Sie die Möglichkeit, mit `n:else` eine alternative Verzweigung anzugeben:

```latte
<strong n:if="$count > 0">In stock {$count} items</strong>

<em n:else>not available</em>
```

Das Attribut `n:else` kann auch in Verbindung mit [`n:ifset` |#ifset-elseifset], [`n:foreach` |#foreach], [`n:try` |#try], [`n:ifcontent` |#n:ifcontent], und [`n:ifchanged` |#ifchanged].


`{/if $cond}`
-------------

Expand Down
22 changes: 20 additions & 2 deletions latte/el/creating-extension.texy
Expand Up @@ -307,7 +307,7 @@ class ForeachNode extends StatementNode
// μια συνάρτηση ανάλυσης που απλά δημιουργεί έναν κόμβο προς το παρόν
public static function create(Latte\Compiler\Tag $tag): self
{
$node = new self;
$node = $tag->node = new self;
return $node;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ class ForeachNode extends StatementNode
public static function create(Latte\Compiler\Tag $tag): self
{
$tag->expectArguments();
$node = new self;
$node = $tag->node = new self;
$node->expression = $tag->parser->parseExpression();
$tag->parser->stream->consume('as');
$node->value = $parser->parseExpression();
Expand Down Expand Up @@ -486,6 +486,24 @@ public function &getIterator(): \Generator
```


AuxiliaryNode
-------------

Εάν δημιουργείτε μια νέα ετικέτα για το Latte, είναι σκόπιμο να δημιουργήσετε μια ειδική κλάση κόμβου για αυτήν, η οποία θα την αντιπροσωπεύει στο δέντρο AST (βλέπε την κλάση `ForeachNode` στο παραπάνω παράδειγμα). Σε ορισμένες περιπτώσεις, μπορεί να βρείτε χρήσιμη την τετριμμένη βοηθητική κλάση κόμβου [AuxiliaryNode |api:Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode], η οποία σας επιτρέπει να περάσετε το σώμα της μεθόδου `print()` και τη λίστα των κόμβων που γίνονται προσβάσιμοι από τη μέθοδο `getIterator()` ως παραμέτρους του κατασκευαστή:

```php
// Latte\Compiler\Nodes\Php\Expression\AuxiliaryNode
// or Latte\Compiler\Nodes\AuxiliaryNode

$node = new AuxiliaryNode(
// body of the print() method:
fn(PrintContext $context, $argNode) => $context->format('myFunc(%node)', $argNode),
// nodes accessed via getIterator() and also passed into the print() method:
[$argNode],
);
```


Μεταγλωττιστής περνάει .[#toc-compiler-passes]
==============================================

Expand Down
15 changes: 15 additions & 0 deletions latte/el/tags.texy
Expand Up @@ -16,6 +16,7 @@
| `{ifset}`... `{elseifset}`... `{/ifset}` | [συνθήκη ifset |#ifset-elseifset]
| `{ifchanged}`... `{/ifchanged}` | [test if there has been a change |#ifchanged]
| `{switch}` `{case}` `{default}` `{/switch}` | [condition switch |#switch-case-default]
| `n:else` | [εναλλακτικό περιεχόμενο για τους όρους |#n:else]

.[table-latte-tags language-latte]
|## Βρόχοι
Expand Down Expand Up @@ -246,6 +247,20 @@ Age: {date('Y') - $birth}<br>
Ωραία.


`n:else` .{data-version:3.0.11}
-------------------------------

Αν γράψετε τη συνθήκη `{if} ... {/if}` με τη μορφή ενός [n:attribute |syntax#n:attributes], έχετε τη δυνατότητα να καθορίσετε μια εναλλακτική διακλάδωση χρησιμοποιώντας το `n:else`:

```latte
<strong n:if="$count > 0">In stock {$count} items</strong>

<em n:else>not available</em>
```

Το χαρακτηριστικό `n:else` μπορεί επίσης να χρησιμοποιηθεί σε συνδυασμό με το [`n:ifset` |#ifset-elseifset], [`n:foreach` |#foreach], [`n:try` |#try], [`n:ifcontent` |#n:ifcontent], και [`n:ifchanged` |#ifchanged].


`{/if $cond}`
-------------

Expand Down
20 changes: 20 additions & 0 deletions latte/en/cookbook/migration-from-latte2.texy
Expand Up @@ -128,6 +128,26 @@ $latte->addExtension(new Nette\Bridges\CacheLatte\CacheExtension($cacheStorage))
```


Tracy
-----

The panel for Tracy is now also activated as an extension.

Old code for Latte 2:

```php
$latte = new Latte\Engine;
Latte\Bridges\Tracy\LattePanel::initialize($latte);
```

New code for Latte 3:

```php
$latte = new Latte\Engine;
$latte->addExtension(new Latte\Bridges\Tracy\TracyExtension);
```


Translations
------------

Expand Down

0 comments on commit 50f27b8

Please sign in to comment.