Passing a parameter to a recursive callable in a filter

The following certainly cannot be ideal:

\procedure my-proc(my-param)
  <$wikify name="my-var" mode="inline" text=`<<my-helper $(my-param)$>>` >
    <!-- Use `my-var` here -->
  </$wikify>
\end my-proc

That call to wikify seems ridiculous. But when I replace it with a $let widget, I get problems. It doesn’t happen with the simplified version above1, but in my more complex recursive environment, I get a recursive transclusion error. I don’t get that with $wikify.

I have posted a sample wiki to http://scott.sauyet.com/Tiddlywiki/Demo/Breadcrumbs/v1/. You can see the effect I’m going for in, for example #Policy1234(II)(A):

The relevant code is in $:/_/my/procedures/crumbs

The (working!) function in question looks like this:

\procedure lineage(tid)
  <$wikify name="parent" mode="inline" text=`<<get-parent $(tid)$>>` >
    <% if [<parent>trim[]!match[]] %>
      <$transclude $variable="lineage" tid=<<parent>> />
    <% endif %> 
    <!-- ... more here ... -->
  </$wikify>
\end lineage

There’s a commented out version included, which looks instead like this:

\procedure lineage(tid)
  <$let parent={{{ [<get-parent>] }}} >
    <% if [<parent>trim[]!match[]] %>
      <$transclude $variable="lineage" tid=<<parent>> />
    <% endif %> 
    <!-- ... more here ... -->
  </$let>
\end lineage

This is the one that ends up with an error.

Can anyone suggest why?

Background

I am trying to redo the initial work I’ve one on a wiki I’ve been working on. But this time, instead of depending on parent and marker fields in the child tiddlers, I would like to do it all from the titles, which already describe a hierarchical structure: Policy1234(II)(A) is a child of Policy1234(II), which is itself a child of Policy1234, and where I need a marker, it’s in the final parenthesized section of the title. I think in the end that will be a lot cleaner. But because of the changed structure, it’s a bit of work. Before I went on to the main content, I decided to do these breadcrumbs first. I tried a number of ways to call to get the title, and kept failing until I tried this $wikify version. But I really feel as though there should be something simpler.




1 For instance this works as expected:

\procedure my-helper(tid)
  {{{ [<tid>uppercase[]] [[-]] [<tid>] +[join[]] }}}
\end my-helper

\procedure my-proc(my-param)
  <$let tid=<<my-param>> my-var={{{ [<my-helper>] }}} >
    The result looks like <<my-var>>.  Is that right?
  </$let>
\end my-proc

Just a passing comment, if you can replace a procedure/macro with a function /filter to generate the required result you will not need to wikify.

  • Even the lookup operator can help with transclusion

I started trying to create the relevant part as a function first. When I failed at that, I moved on to a procedure. I may try again.

How is that?

It is effectivly a transcluding filter operator, or more precisly it brings content from a title/field into the filter, but I supose {title!!fieldname} does that as well.

Perhaps it was premature for me to mention it, I was recently trying to hack things here. In my exploration I am prepared to “look outside the box”, especialy with recent enhancements such as functions and the backtick attributes, which are evaluated before the final render (wikification).