Proposed <% if %> shortcut syntax

Thank you for clarification.

The problem I see with comparing start and end-markers only is that they are missing context. I think they should be compared with some code.

\procedure test(animal)
<% if [<animal>match[Elephant]] %>
  It is an elephant
<% elseif [<animal>match[Giraffe]] %>
    It is a giraffe
<% else %>
    It is completely unknown
<% endif %>
\end

\procedure test(animal)
{% if [<animal>match[Elephant]] %}
  It is an elephant
{% elseif [<animal>match[Giraffe]] %}
    It is a giraffe
{% else %}
    It is completely unknown
{% endif %}
\end

<<test "Giraffe">>

I personally think the second syntax is more visible. Especially if we compare the first line with the filter syntax and variables in them. I think the similarity to existing << markers is more of a disadvantage than an advantage

<% if [<animal>match[Elephant]] %>

vs

{% if [<animal>match[Elephant]] %}

For tiddler titles we do have a warning in the UI that says:

Warning: avoid using any of the characters | [ ] { } in tiddler titles

There is a higher chance that tiddler titles end with %> than %}. Usually the end-marker can cause problems with the TW parser.

Just my thoughts
-m

On further reflection it occurs to me that the proposed syntax is too similar to the new text substitution syntax and that using an angle bracket would indeed be a better choice.

Substitution syntax:
${ filter expression }$

\procedure test(animal)
{% if [<animal>match[Elephant]] %}
  It is an elephant
{% else %}
  {% if [<animal>match[Giraffe]] %}
    It is a giraffe
  {% else %}
    It is completely unknown
  {% endif %}
{% endif %}
\end

<% if [<animal>match[Elephant]] %>
  It is an elephant
<% elseif [<animal>match[Giraffe]] %>
    It is a giraffe
<% else %>
    It is completely unknown
<% endif %>
2 Likes

That’s a point but the substitution syntax is either part of a filter or a widget parameter.

So it’s either covered in braces or back-ticks. I think it’s not stand alone as in your example.

I agree. I take @pmario’s point that the substitution syntax is localised to parameters using textual substitution, but I don’t like that the two usages invert the ordering (ie ${thing}$ vs. {%thing%}). I’m going to go ahead and change the PR.