forked from trejjam/skoleni-13_14-11-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
87 lines (64 loc) · 1.41 KB
/
index.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require 'sandbox/vendor/autoload.php';
Tracy\Debugger::enable(FALSE);
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
class BoldMacro implements Latte\IMacro
{
function initialize() {}
function finalize() {}
function nodeOpened(Latte\MacroNode $node)
{
//dump($node);
}
function nodeClosed(Latte\MacroNode $node)
{
//dump($node);
$node->openingCode = '<b>';
$node->closingCode = '</b>';
}
}
class BoldMacro2 extends Latte\Macros\MacroSet
{
function install()
{
//$latte->addMacro('bold', $this);
$this->addMacro('bold',
//'echo %escape(%modify($presenter->link(%node.word, %node.array?)))',
[$this, 'boldOpened'],
'echo "</b>"',
'AHOJ'
);
}
function boldOpened($node, $writer)
{
//dump($node);
return $writer->write('echo %escape(%modify($presenter->link(%node.word, %node.array?)))');
}
}
$latte->addFilter('xx', function($s) {
return new Latte\Runtime\Html('**' . $s . '**');
});
$latte->addFilter(NULL, function($name, $s) {
return $s;
});
$latte->onCompile[] = function($latte) {
$macro = new BoldMacro2($latte->getCompiler());
$macro->install();
//$latte->addMacro('bold', new BoldMacro2);
};
/*echo $latte->compile('
{$var}
<body title=ahoj>
{if true}
<p id=123 n:bold>
{bold presenter:action, 123, abc, $var |trim}{$var}{/bold}
</p>
{/if}
</body>
');*/
$latte->render('
<p>{$var|yyy}</p>
', array(
'var' => '<b>',
));