applyHtmlMacros function applying macros twice

0 views
Skip to first unread message

Clint Checketts

unread,
Aug 14, 2006, 11:50:43 PM8/14/06
to Tiddly...@googlegroups.com
In trying to find a good way to re-use templates I've stumbled upon a great solution. It essentially re-uses the inserted content's template inside the parent tiddler. This makes for simple templates (since they can be re-used).

However it uncovers a bug/feature in the applyHtmlMacros function. The function works by starting at a root element and looking for all children with a 'macro' attribute and executing the corresponding macro. The problem is that when the inserted templates are included the applyHtmlMacros functions covers them and they insert their content (that is the expected behavior) but then the containing tiddler calls it again triggering the macros again but in the context of the parent tiddler (this is incorrect behavior)

To fix this the applyHtmlMacros function just needs to call
 e.removeAttribute("macro");
after the getAttribute call. That way it cleans up after itself and removes the macro calls. There are other solutions, I've included this one here: http://checkettsweb.com/tw/beta.html#ShowQuotes

I think this would be a great inclusion in the core (regarding the applyHtmlMacro tweak, not necessarily the showQuotes macro there)

-Clint

Simon Baird

unread,
Aug 15, 2006, 12:18:20 AM8/15/06
to Tiddly...@googlegroups.com
Agree.

Jeremy Ruston

unread,
Aug 16, 2006, 9:45:19 AM8/16/06
to Tiddly...@googlegroups.com
I've created a ticket for this issue:

http://trac.tiddlywiki.org/tiddlywiki/ticket/138

Cheers

Jeremy


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

Reply all
Reply to author
Forward
0 new messages