-
-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathFormsExtension.php
More file actions
50 lines (40 loc) · 1.16 KB
/
FormsExtension.php
File metadata and controls
50 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Bridges\FormsLatte;
use Latte;
/**
* Latte v3 extension for Nette Forms.
*/
final class FormsExtension extends Latte\Extension
{
public function getTags(): array
{
return [
'form' => [Nodes\FormNode::class, 'create'],
'formContext' => [Nodes\FormNode::class, 'create'],
'formContainer' => [Nodes\FormContainerNode::class, 'create'],
'label' => [Nodes\LabelNode::class, 'create'],
'input' => [Nodes\InputNode::class, 'create'],
'inputError' => [Nodes\InputErrorNode::class, 'create'],
'formPrint' => [Nodes\FormPrintNode::class, 'create'],
'formClassPrint' => [Nodes\FormPrintNode::class, 'create'],
'n:name' => fn(Latte\Compiler\Tag $tag) => yield from strtolower($tag->htmlElement->name) === 'form'
? Nodes\FormNNameNode::create($tag)
: Nodes\FieldNNameNode::create($tag),
];
}
public function getProviders(): array
{
return [
'forms' => new Runtime,
];
}
public function getCacheKey(Latte\Engine $engine): array
{
return ['version' => 2];
}
}