Wrap wikitext conditionally within a html tag / text substitution inside html tag

Hi @rguy I may finally have understood your idea. What about this:

\define is_wrapped() yes
\define is_styled() yes

<$genesis $type={{{ [<is_wrapped>match[yes]then[section]] }}} 
          $names=" [<is_styled>match[yes]then[style]] [<is_wrapped>match[yes]then[inert]]" 
          $values="[<is_styled>match[yes]then[val1]]  [<is_wrapped>match[yes]then[val2]] ">
This text only gets wrapped with a `<section>` element when the `is_wrapped` macro/variable is set to ''yes''.
</$genesis>

Note that this only works fully with the 5.2.6 prerelease: before this release, the $type attribute cannot be set to a blank value. The transcluded filter for $type returns nothing when <is_styled> is not set to yes, while $names and $values filters also change their returned values depending of the value of <is_wrapped>.

I don’t know if this will help you. I figured it out recently answering my own question.

I wrapped the open tag in two lists, one including the tag, one not including it.

<$list filter="[<something>mycondition[param]]">
        <section inert>
</$list>
<$list filter="[<something>!mycondition[param]]">
        <section>
</$list>

Notice the ! in the second filter.

It’s not clear if it would help, but it worked for me.

@rguy based on decades of experience with TiddlyWiki I am confident you are making some assumptions that make this whole thread and your support much more complicated.

I could certainly help you a lot more if I/we did not have to second guess this which you have not yet answered;

  • This is a design assumption which I think is incorrect, maybe correct in a pure HTML document but not in TiddlyWiki. This is why returning to what the desired outcome is, not how would help.
  • Well that illustrates to me in part where I can help you, because I do see the relationships.

It is up to you @rguy if you want a substantial answer to the technical questions you are posing please step back and describe the broader picture so I/we can provide better solutions and break you out of particular path you are currently following.