File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Tester \Assert ;
4+
5+
6+ require __DIR__ . '/../bootstrap.php ' ;
7+
8+
9+ $ latte = new Latte \Engine ;
10+
11+ Assert::matchFile (
12+ __DIR__ . '/expected/UIMacros.snippet4.phtml ' ,
13+ $ latte ->compile (__DIR__ . '/templates/snippets.block.latte ' )
14+ );
Original file line number Diff line number Diff line change 1+ <?php
2+ // source: %A%
3+
4+ class Template%a% extends Latte \Template
5+ {
6+ public $ blocks = [
7+ '_snippet ' => ['blockSnippet ' , 'html ' ],
8+ 'block1 ' => ['blockBlock1 ' , 'html ' ],
9+ '_outer ' => ['blockOuter ' , 'html ' ],
10+ 'block2 ' => ['blockBlock2 ' , 'html ' ],
11+ ];
12+
13+
14+ function render ()
15+ {
16+ %A%
17+ // main template
18+ if ($ this ->tryRenderParent (get_defined_vars ())) return;call_user_func (reset ($ this ->blockQueue ['_snippet ' ]), $ this ->params ) ?>
19+
20+
21+ <div id="<?php echo $ _control ->getSnippetId ('outer ' ) ?> "><?php call_user_func (reset ($ this ->blockQueue ['_outer ' ]), $ this ->params ) ?>
22+ </div><?php
23+ }
24+
25+
26+ function blockSnippet ($ _args )
27+ {
28+ extract ($ _args );
29+ $ _control ->redrawControl ('snippet ' , FALSE );
30+
31+
32+ }
33+
34+
35+ function blockBlock1 ($ _args )
36+ {
37+ extract ($ _args )
38+ ?> <div<?php echo ' id=" ' . $ _control ->getSnippetId ('snippet ' ) . '" ' ?> >
39+ static
40+ </div>
41+ <?php
42+ }
43+
44+
45+ function blockOuter ($ _args )
46+ {
47+ extract ($ _args );
48+ $ _control ->redrawControl ('outer ' , FALSE )
49+ ?> begin
50+ end
51+ <?php if (isset ($ this ->local ->dynSnippets )) return $ this ->local ->dynSnippets ;
52+ }
53+
54+
55+ function blockBlock2 ($ _args )
56+ {
57+ extract ($ _args )
58+ ?> <div<?php echo ' id=" ' . ($ this ->local ->dynSnippetId = $ _control ->getSnippetId ("inner- $ id " )) . '" ' ?> >
59+ dynamic
60+ </div>
61+ <?php
62+ }
63+
64+ }
Original file line number Diff line number Diff line change 1+ <div n:snippet =" snippet" n:block =" block1" >
2+ static
3+ </div >
4+
5+
6+ { snippet outer}
7+ begin
8+ <div n:snippet =" inner-$id" n:block =" block2" >
9+ dynamic
10+ </div >
11+ end
12+ { /snippet}
You can’t perform that action at this time.
0 commit comments