Cascades: TiddlerColourFilter & TiddlerIconFilter possible simplification/abstraction?

How can I simplify/abstract the Color and Icon cascades? I’m currently having the following:

$:/tags/TiddlerColourFilter

[kind[infusion]then{infusion!!color}]
[kind[coffee]then{coffee!!color}]
[kind[wine]then{wine!!color}]
etc

$:/tags/TiddlerIconFilter

[kind[infusion]then{infusion!!icon}]
[kind[coffee]then{coffee!!icon}]
[kind[wine]then{wine!!icon}]
etc

Which as far as I understand says

If current tiddler’s kind field is “infusion”, then apply the icon field of the infusion tiddler

I want to add many more kinds like salad, beer, pasta etc. Thus I’ll have to add many more lines like the above.

Could I somehow write a more abstract rule/filter/definition that would describe something like:

If current tiddler has a defined kind field, use its value to get the color/icon to be applied

I tried the following but it doesn’t work, I think because it gets the color field from the actual kind tiddler, and not what that links to:

[has[kind]then[get[kind]get[color]]

then[...] is using square brackets, which means it expects a literal text value, not more filter syntax

Try this: [get[kind]get[color]]

Notes:

  • You don’t need the initial has[kind] filter operator, since get[kind] includes an implicit check for a non-blank ‘kind’ field value.
  • Once you get the kind value, the subsequent get[color] DOES get the color field value from the actual kind tiddler.
  • If the current tiddler doesn’t have a kind value, or the kind tiddler doesn’t have a color value, the cascade falls through to the next cascade item.

enjoy,
-e

Brilliant, it works exactly as I hoped it would. It makes things much tidier, thank you!