Custom Styles Based of a Field of Tiddler

Referring to:

https://tiddlywiki.com/prerelease/#Custom%20Styles%20FAQ

Is it possible to have custom styles for all tiddlers have a field like job?

Is there anything similar to [data-tags*="bar"]...

I use something like this (put it in a tiddler tagged with $:/tags/Stylesheet and type is unset or is Tiddlywiki 5 (text/vnd.tiddlywiki)

\define assign-css()
\rules only
[data-tiddler-title="$(currentTiddler)$"] .tc-tiddler-body { color:red; }
\end
<$list filter="[all[tiddlers]has:field[job]]">
<<assign-css>><br>
</$list>

The issue here is, you may have a very big styles tiddler! but it works fine!

3 Likes

Remember there is a standard field called class that can be added to tiddlers containing class name(s).

In effect this is " Custom Styles Based of a Field of Tiddler" via a class.

The reason I mention it is if you reverse engineer this by looking at how the core does it, you would find a more efficient way to do this for a custom field.

In the mean time you just set the class field of tiddlers that require the custom “styles” via a CSS class you define in a stylesheet.