Loop

You can use the "for" command to loop

define loop variables

Define a loop variable in the JSON file, which should be of type array[json]

main.json
{
    "variable": "hello world",
    "loop": [{"name": "content1", "is_show":true},{"name": "content2","is_show": false},{"name": "content3", "is_show": true}]
}

use loop

To use loops in a markdown file, it is necessary to start with the "for-" or "forn-" directive and start with "<--- {end}--->" end.

Instructions in the loop can all parse local parameters in the for variable.

Note: "forn-" followed by an integer represents the number of cycles

main.md
<!--{for-loop}-->
# <!--{v-name}-->
<!--{if-is_show}-->
hello world
<!--{end}-->
<!--{end}-->

<!--{forn-6}-->
hello world
<!--{end}-->

compiler results

dist/build.md
# content1
hello world
# content2

# content3
hello world

hello world
hello world
hello world
hello world
hello world
hello world

Last updated