Text colourized based on User fields: color

I have set different color using the User fields color in several tiddlers and I would like to retrieve them to display some text depending of this User fields color but could not get it to work with the code below:

<$list filter="[tag[toto]]">
<$link/> for ‘’<$text text={{!!node}}/>’’ - @@color:{{!!color}};Status:@@ <$text text={{!!status}}/>
</$list>

Any suggestion ?

welcome @Thierry

I suggest you use the </> button to wrap code.

A quick suggestion see in Styles and Classes in WikiText @@ is a block markup.

Perhaps try a space before Status: to separate it from the style/class

<$list filter="[tag[toto]]">
<$link/> for ‘’<$text text={{!!node}}/>’’ - @@color:{{!!color}}; Status:@@ **<$text text={{!!status}}/>**
</$list>

…display some text depending of this User fields color…
@@color:{{!!color}};Status:@@

The @@...; content@@ syntax is basically shorthand for <span style="...">content</span> and when the above wikitext is parsed, it results in the following HTML:
<span class="tc-inline-style" style="color:{{!!color}};"> Status:</span>

The problem is that you are trying to mix literal text syntax (color:) with a wiki reference ({{!!color}}) within the style="..." attribute value and the TWCore does not parse text attribute values. Instead, they are simply passed along for handling by the TWCore code that processes the particular widget.

However, the TWCore does parse attribute values that are transclusions or variable references. Thus, you can achieve the results you want by using “filtered transclusion” to construct the entire style attribute value, like this:
<span style={{{ [[color:]addsuffix{!!color}] }}}>Status:</span>

enjoy,
-e

3 Likes

@EricShulman This begs me to ask, would it be difficult to teach tiddlywiki to parse attributes first, if they contain a “{” or “<” or just use the substitution $format$.

  • I believe it would already handle a substitution this way eg $something$ $(something)$
  • I wonder if there were a way to have an inline substitution ie; without needing a call to a macro and pass a parameter?
    • eg wild speculation $<<varname>> - {{!!fieldname}}$ wikifies and returns text as if a substitution.

This has being a stumbling block for many, for years.

Actualy something similar would be evaluating a variable like wikify before use, to ensure it returns the result not the macros wikitext. I wondered if at least in filters we could trigger this with $(varname)$ even when not in a macro. One could imagin ${textreference}$

So one could concatinate with attribute="${textreference}$:$(varname)$;"

It would be consistent at least.

Basicaly it a substitution without the otherwise implied delimiters.