Creating a new template failing at inline styles

48 views
Skip to first unread message

T. E. Sanders

unread,
Feb 20, 2020, 5:06:44 PM2/20/20
to TiddlyWiki
Hey all, I'm trying to write a template. It works as a template in that it renders the currentTiddler, but if I try to use the color from the tiddler on the background, it doesn't evaluate and simply renders the text as-is.

For example
\whitespace trim
\define col() {{!!color}}
<$set name="transclusion" value=<<currentTiddler>>>
    <span style="background-color:<<col>>" >
    <<currentTiddler>>
    </span>
</$set>

doesn't work. Neither did style="background-color:{{!!color}}" and it doesn't matter if I use quotes or not. Clearly I'm missing some syntax or something.
The goal is just to make the background the color set in the color field. Ideas?

Mark S.

unread,
Feb 20, 2020, 5:27:45 PM2/20/20
to TiddlyWiki
Not sure what the "set" was supposed to be doing. If I understand what you want, this seems to work:

\whitespace trim
   
<span style={{{ [{!!color}addprefix[background-color: ]] }}} >
   
<<currentTiddler>>
   
</span>


T. E. Sanders

unread,
Feb 20, 2020, 5:33:08 PM2/20/20
to TiddlyWiki
Oh man THANK YOU! Out of all the digging I didn't spot anything that looked like this. Works great. However, now I need to make the foreground work in contrast to that. I know there's a way to do it as I've seen it in TiddlyWiki here and there. It seems to be aware when the background is too dark to create white text versus dark text. 

What magic is that?

T. E. Sanders

unread,
Feb 20, 2020, 6:37:42 PM2/20/20
to TiddlyWiki
Figured it out with this:

<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">


On Thursday, February 20, 2020 at 4:27:45 PM UTC-6, Mark S. wrote:
Reply all
Reply to author
Forward
0 new messages