How to write JS template for Transclusion?

95 views
Skip to first unread message

LinOnetwo

unread,
May 6, 2019, 6:29:37 AM5/6/19
to TiddlyWiki
(function() {
  exports
.name = 'listtosentence';

  exports
.params = [{ name: 'text', defalue: '' }];

  exports
.run = function(text) {
   
return text
     
.split(/\s?\*\s/)
     
.filter(it => it)
     
.join('、');
 
};
})();
I've writen this macro

LinOnetwo

unread,
May 6, 2019, 6:31:30 AM5/6/19
to TiddlyWiki
I can't write wikitext or this forum will throw error on console...So:



在 2019年5月6日星期一 UTC+8下午6:29:37,LinOnetwo写道:

Mark S.

unread,
May 7, 2019, 12:39:22 AM5/7/19
to TiddlyWiki
You would need to wrap it in a tiddler, and then use that tiddler for transclusion.

So maybe (untested)

Tiddler: MyTemplate
Text: <$macrocall $name=listtosentence text={{!!text}}/>

Then call the transclusion like:

{{SomeListTiddler||MyTemplate}}

Notice that it uses {{!!text}} to pick up the text of the tiddler to which the template is applied.

Good luck!

LinOnetwo

unread,
May 7, 2019, 6:09:28 AM5/7/19
to TiddlyWiki
Oh, this actually makes an infinite loop, and my page blocks....
Reply all
Reply to author
Forward
0 new messages