This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -587,3 +587,57 @@ You can optionally specify the name of the macro in `endmacro`:
587
587
``` html
588
588
{% macro heading(arg) %}<p >{{arg}}</p >{% endmacro heading %}
589
589
```
590
+
591
+ You can also specify arguments by their name (as defined in the macro):
592
+
593
+ ```
594
+ {% macro heading(arg, bold) %}
595
+
596
+ <h1>{{arg}} <b>{{bold}}</b></h1>
597
+
598
+ {% endmacro %}
599
+
600
+ {% call heading(bold="something", arg="title") %}
601
+ ```
602
+
603
+ You can use whitespace characters around ` = ` :
604
+
605
+ ```
606
+ {% call heading(bold = "something", arg = "title") %}
607
+ ```
608
+
609
+ You can mix named and non-named arguments when calling a macro:
610
+
611
+ ```
612
+ {% call heading("title", bold="something") %}
613
+ ```
614
+
615
+ However please note than named arguments must always come ** last** .
616
+
617
+ In this case, the named arguments will be passed to the related parameter and then the other
618
+ arguments will be placed in what remains. Let's explain it in code:
619
+
620
+ ```
621
+ {% macro heading(arg1, arg2, arg3, arg4) %}
622
+ {% endmacro %}
623
+
624
+ {% call heading("something", "b", arg4="ah", arg2="title") %}
625
+ ```
626
+
627
+ First it'll be replaced like this:
628
+
629
+ ```
630
+ arg1 =
631
+ arg2 = "title"
632
+ arg3 =
633
+ arg4 = "ah"
634
+ ```
635
+
636
+ Then ` arg1 ` and ` arg3 ` will be filled in the order of the arguments given to the macro call:
637
+
638
+ ```
639
+ arg1 = "something"
640
+ arg2 = "title"
641
+ arg3 = "b"
642
+ arg4 = "ah"
643
+ ```
You can’t perform that action at this time.
0 commit comments