File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ {% - macro list (list ) -%}
2
+ <ul >
3
+ {% - for item in list %}
4
+ <li >{{item}}</li >
5
+ {% - endfor %}
6
+ </ul >
7
+ <ol >
8
+ {% - for item in list %}
9
+ <li >{{item}}</li >
10
+ {% - endfor %}
11
+ </ol >
12
+ {% - endmacro -%}
13
+
14
+ {% - for foo in foos %}
15
+ {% call list (foo .list ) %}
16
+ {% - endfor %}
Original file line number Diff line number Diff line change 1
1
use askama:: Template ;
2
+ use std:: collections:: BTreeSet ;
2
3
3
4
#[ derive( Template ) ]
4
5
#[ template( path = "macro.html" ) ]
@@ -73,3 +74,13 @@ fn str_cmp() {
73
74
let t = StrCmpTemplate ;
74
75
assert_eq ! ( t. render( ) . unwrap( ) , "AfooBotherCneitherD" ) ;
75
76
}
77
+
78
+ #[ derive( Template ) ]
79
+ #[ template( path = "macro-iter.html.j2" ) ]
80
+ struct MacroIterTemplate {
81
+ foos : Vec < Foo > ,
82
+ }
83
+
84
+ struct Foo {
85
+ list : BTreeSet < String > ,
86
+ }
You can’t perform that action at this time.
0 commit comments