Color text based on a field

207 views
Skip to first unread message

sin...@gmail.com

unread,
Nov 25, 2020, 8:33:22 AM11/25/20
to TiddlyWiki
Hello, 

I am trying to do something I thought would be easy, but it turned out not to be: I want to color text on a tiddler with a color stored in a field. The naive solution would look like: (color_field has the value "blue")


@@color:{{!!color_field}};
bla
@@

But that does not work. Is it possible to do what I want?

Thanks!

Eric Shulman

unread,
Nov 25, 2020, 9:48:26 AM11/25/20
to TiddlyWiki
On Wednesday, November 25, 2020 at 5:33:22 AM UTC-8 sin...@gmail.com wrote:
I am trying to do something I thought would be easy, but it turned out not to be: I want to color text on a tiddler with a color stored in a field. The naive solution would look like: (color_field has the value "blue")
@@color:{{!!color_field}};
bla
@@

While it seems like a reasonable usage, this is another instance where you can't directly combine different kinds of wiki syntax.  In the above example, the TWCore parser would first have to replace {{!!color_field}} with it's value (e.g., "blue"), and then perform a second parsing action to process the resulting @@color:blue; bla @@ syntax.

Fortunately, there is a way to achieve the results you want, by using an HTML <span> instead of "@@", where the span has a style attribute that is constructed using "filtered transclusion", like this:

<span style={{{ [[color:]addsuffix{!!color_field}] }}}>
bla
</span>

enjoy,
-e

sin...@gmail.com

unread,
Dec 1, 2020, 4:01:36 AM12/1/20
to TiddlyWiki
Better late than never: thanks a lot for the help! 😊
Reply all
Reply to author
Forward
0 new messages