How to macro > var > macro ??

70 views
Skip to first unread message

Rustem

unread,
Jul 24, 2017, 9:57:39 PM7/24/17
to TiddlyWiki
I have these macros defined

\define colorize() color:$(_c)$

\define cn()
 
<span style=<<colorize>>>
    some text
 
</span>
\end


It works if I specify the color directly

<$vars _c=red><<cn>></$vars>

But how do I specify the color using a macro? This doesn't work:

<$vars _c=<<color tiddler-background>>><<cn>></$vars>

Is it possible?

Thanks.

--R

Mat

unread,
Jul 24, 2017, 11:02:33 PM7/24/17
to TiddlyWiki
Try with the setwidget, or perhaps wikifywidget instead. The varswidget is not as powerful and I don't think it can handle macrocalls as arguments. Not sure.

<:-)

Rustem

unread,
Jul 25, 2017, 2:48:50 AM7/25/17
to TiddlyWiki
Tried with set widget, same, didn't work.

Danielo Rodríguez

unread,
Jul 25, 2017, 3:12:16 AM7/25/17
to TiddlyWiki
Try enclosing the macro call on quotes <$set value="<<macro>>">

Jeremy Ruston

unread,
Jul 25, 2017, 4:20:06 AM7/25/17
to tiddl...@googlegroups.com
Hi Rustem,

Try this:

\define colorize() color:$(_c)$;

\define cn()
<span style=<<colorize>>>
some text
</span>
\end

Specifying a color directly:

<$vars _c=red><<cn>></$vars>

Specifying a color using a macro:

<$wikify name="_c" text="<<color muted-foreground>>">
<<cn>>
</$wikify>

Best wishes

Jeremy.

> On 25 Jul 2017, at 08:12, Danielo Rodríguez <rdan...@gmail.com> wrote:
>
> Try enclosing the macro call on quotes <$set value="<<macro>>">
>
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
> To post to this group, send email to tiddl...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/85b2e5b9-4874-45a6-af6c-aa3db6ce3ddd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Eric Shulman

unread,
Jul 25, 2017, 4:20:52 AM7/25/17
to TiddlyWiki
On Monday, July 24, 2017 at 6:57:39 PM UTC-7, Rustem wrote:
I have these macros defined
... 
It works if I specify the color directly
<$vars _c=red><<cn>></$vars>

But how do I specify the color using a macro? This doesn't work:
<$vars _c=<<color tiddler-background>>><<cn>></$vars>

 
The problem with using the <<color>> macro as a parameter value in the <$vars> widget is that the macro doesn't return a color value directly.  Instead, it returns transclusion widgets that, if subsequently rendered, results in a color value.  Here's the core definitions (from $:/core/macros/CSS):

\define colour(name)
<$transclude tiddler={{$:/palette}} index="$name$"><$transclude tiddler="$:/palettes/Vanilla" index="$name$"/></$transclude>
\end

\define color(name)
<<colour $name$>>
\end

To retrieve the actual color *value*, you can use the <$wikify> widget, which "captures" the rendered output from the macro and stores that in a variable, like this:

<$wikify name="_c" text=<<colour tiddler-background>>><<cn>></$wikify>

Note: in this example, "tiddler-background" produces "invisible" text, since the foreground text color is the same as the background tiddler color.  I assume that was your intention.

Let me know how it goes.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Rustem

unread,
Jul 25, 2017, 5:38:40 AM7/25/17
to TiddlyWiki
It works with <$wikify> widget. Thanks everyone!
Reply all
Reply to author
Forward
0 new messages