variable and html tag

79 views
Skip to first unread message

Mohammad

unread,
Nov 18, 2018, 6:37:26 AM11/18/18
to TiddlyWiki
I have a macro as bellow. It uses a helper macro to split input into several words using space as delimiter
  • Macro
\define _split-fadeIn-class()
<$list filter="$(cls)$ +[splitbefore[ ]]" variable="fcls">
mr-fadeIn-<<fcls>>
</$list>
\end

\define colorful(param1)
<$vars cls="$param1$">
<span class=<<_split-fadeIn-class>> >
 This is test
</span>
</$vars>
\end


  • I call it like below

<<colorful "redcls bluecls">>


It seems this line does not work correctly:
<span class=<<_split-fadeIn-class>> >

  • Any idea?

Cheers
Mohammad

TonyM

unread,
Nov 18, 2018, 7:43:31 AM11/18/18
to TiddlyWiki
Mohammad

At first glance you are not closing <<__ with __>>

Thete may me more, but start there.

Tony

Mark S.

unread,
Nov 18, 2018, 9:39:47 AM11/18/18
to TiddlyWiki
It looks like you're trying to concatenate with this:

mr-fadeIn-<<fcls>>

But that probably won't work (I know, it looks like it works when you call _split-fadeIn-class, but that's an illusion) You probably either need to call another macro to concatenate
mr-fadeIn- and <<fcls>> or you need to use wikify to put them together.

HTH
-- Mark

Mohammad

unread,
Nov 18, 2018, 10:50:15 AM11/18/18
to TiddlyWiki
Hello Mark,
 The real usage is the macro colorful is called with a list of classes like red and bold.
It then calls a helper macro to split the cls parameter "red bold" and makes mr-fadeIn-red and mr-fadeIn-bold.
to create  .

I donot have problem with concatenation. I think the span tag does not work here as the macro does not work correctly!

Mohammad


Mark S.

unread,
Nov 18, 2018, 12:20:12 PM11/18/18
to TiddlyWiki
When you do this:

mr-fadeIn-<<fcls>>

You're trying to concatenate "mr-fadeIn" with <<fcls>> . In my experience, this kind of concatenation never works. You always need something like mr-fadeIn-$fcls$ or
mr-fadeIn-$(fcls)$ (via a separate macro) or you need to pass it to a wikify widget (<$wikify text="mr-fadeIn<<fcls>>" .../>

Good luck
-- Mark

Mohammad

unread,
Nov 18, 2018, 1:45:18 PM11/18/18
to TiddlyWiki
Hi Tony,
 I did not get what you mean!

/Mohammad 

Mohammad

unread,
Nov 18, 2018, 2:32:14 PM11/18/18
to TiddlyWiki
Mark,
 Take a look at below solution

\define m1(p)
<$set name=cls filter="$p$ +[splitbefore[ ]] +[addprefix[mr-fadeIn-]]">
<span class=<<cls>> > This is a test </span>
</$set>
\end
<style>
.mr-fadeIn-red{color:red;}
.mr-fadeIn-yellow{background-color:yellow;}
</style>

<<m1 "red yellow">>


This works! What is your opinion?

Mohammad

Mohammad

unread,
Nov 18, 2018, 2:51:39 PM11/18/18
to TiddlyWiki
This is another version!

\define fin() $(cls)$ mr-contents
\define m1(p)
<$set name=cls filter="$p$ +[splitbefore[ ]] +[addprefix[mr-fadeIn-]]">
<span class=<<fin>> > This is a test </span>
</$set>
\end
<style>
.mr-fadeIn-red{color:red;}
.mr-fadeIn-yellow{background-color:#dadada;}
.mr-contents{border:1px solid blue;padding:5px;}
</style>

<<m1 "red yellow">>

Best
Mohammad

Mark S.

unread,
Nov 18, 2018, 3:32:27 PM11/18/18
to TiddlyWiki
In these two recent examples, you are not concatenating anything. So everything works. In your first post, your macro was attempting to concatenate.

Try rewriting colorful like this:

\define colorful(param1)
<$vars cls="$param1$">
<$wikify text=<<_split-fade-In-class>> name=joinme>
<span class=<<joinme>> >
 
This is test
</span>
</
$wikify>
</$vars>
\end

In my test, when I inspect "This is a test", it now shows classes "mr-fadeIn-redcls mr-fadeIn-bluecls".

Good luck!
-- Mark

Mohammad

unread,
Nov 18, 2018, 3:55:55 PM11/18/18
to TiddlyWiki
Many thanks Mark!
Reply all
Reply to author
Forward
0 new messages