[TW5] This time rendering wikitext inside a tiddler using a widget.

89 views
Skip to first unread message

Jed Carty

unread,
Feb 26, 2015, 2:28:46 AM2/26/15
to tiddly...@googlegroups.com
I made a simple calendar widget that given a year and a month will build a calendar for that month with the correct layout. What I would like to do is to be able to give the widget a macro that it will run inside each day on the calendar to list things for that day or whatever you want it to do. The problem Is that I can't figure out how to get the macro to actually get wikified. The html part that builds the calendar works fine, I just can't do anything with it.

Here is what it currently does, I am hoping that I am just missing a step and fixing it will be simple.

Any suggestions?
Message has been deleted

Astrid Elocson

unread,
Feb 27, 2015, 4:02:00 AM2/27/15
to tiddly...@googlegroups.com
HI Jed,

Your widget's execute method is constructing a string containing <$macrocall …> which it then immediately injects into a DOM node. This means you're not giving TiddlyWiki a chance to parse the string as WikiText.

I think the execute method needs to construct a widget tree for the child widgets (the macro call in your case), and the render method can then call this.renderChildren. Have a look at the code of any widget that has children, such as reveal.

– æ

BJ

unread,
Feb 27, 2015, 5:47:08 AM2/27/15
to tiddly...@googlegroups.com

To add to what Astrid said,
you need to call the tw5 parser instead using innerHTML. I think it should be:

        parser = this.wiki.parseText("text/vnd.tiddlywiki",calendarString,{parseAsInline: false});
        parseTreeNodes = parser ? parser.tree : [];
        this.makeChildWidgets(parseTreeNodes);

cheers

BJ

Jed Carty

unread,
Feb 27, 2015, 2:55:43 PM2/27/15
to tiddly...@googlegroups.com
Thanks! That is exactly what I needed. The result is here http://inmysocks.tiddlyspot.com/#Calendar%20Plugin

BJ

unread,
Feb 27, 2015, 5:58:05 PM2/27/15
to tiddly...@googlegroups.com
nice!

On 27 February 2015 at 19:55, Jed Carty <inmy...@gmail.com> wrote:
Thanks! That is exactly what I needed. The result is here http://inmysocks.tiddlyspot.com/#Calendar%20Plugin

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywikidev/QjJ0YkkJPkE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages