How to use ^indent()^

I’m at a total loss…I want to be able to build bulleted a list from a note’s children, and if some of those notes have children, I want those notes to be indented under their parents. I tried modeling this after the OPML template, but I really don’t understand how indent works, e.g. ^indent("\t",^value($OutlineDepth(parent)-1))^.

I wonder if anyone has attempted something similar to this.

OK, the OPML version builds from the doc root and as $OutlineDepth as root is 1 and we generally don’t indent the first level, we want to use $OutlineDepth - 1. Then we march on down using $OutlineDepth(parent)-1)

But you are starting from a note at an arbitrary $OutlineDepth which will vary by where the top level exported document lives. So you need to cache the current indent level as you go, e.g. in a Number attribute at $MyIndent in a note at /config, i.e. at $MyIndent("config").

At the top of the starting template (holding the top level list opening <ul> or <ol>) you add:

^action($MyIndent("config")=1;)^

Now, in your recursing template, you use and increment $MyIndent("config") remembering to de-increment at the end of the template, so as the each branch completes the next discrete branches starts with the right increment.

Lastly, in the starting template, at the end, clear up the counter:

^action($MyIndent("config");)^

Essentially you’ll use a common counter setting/incrementing/de-incrementing it as you go and setting the result to default when done.

Tip: _Don’t be tempted to do this in your working file but make a test doc with minimal $Text/content so you can concentrate on getting the indenting right. Only then port it to your working file.

V. busy to day or I’d try and post a demo file (sorry!)

1 Like

We’ll, I eventually figured out how to use ^indent()^. Turns out it was NOT what was needed.

In the end the answer was terribly simple. To generate a bullet list from a list of notes where some children have their own children you need two templates, a parent to open the list and one to process the children and the children’s children.

Template 1:

<b><u>^title^</u></b><br>
^text^<br>
<ul>
^children(/Templates/tIndentedList/tIndentedList item)^
</ul>

Template 2

<b><u>^title^</u></b><br>
^text^<br>
<ul>
^children(/Templates/tIndentedList/tIndentedList item)^
</ul>