I wish to implement the following functionality, using JS macro, defining 
the macro with name M. 

Whenever I use a macro <<M tiddler_name : "New Tiddler">> , then it creates 
a Tiddler with title "New Tiddler". Then the macro presents this link [[New 
Tiddler]]. The point is that the macro will create the Tiddler for me (with 
some starting content , customisable in JS) if none have already been 
created. 

Example code would be: 

function run(tiddler_name){
- Check if wiki has tiddler with title tiddler_name
- If not, create a tiddler of title tiddler_name and content "default 
content" 
- Return [[tiddler_name]]
}

I would like to know if this is safe. The documentation states: 

"Macros are just used to return a chunk of wikitext for further processing. 
They should not make modifications to tiddlers in the wiki store. The 
reason is that you cannott control when the macro is called; it may be 
called repeatedly as part of refresh processing. So it is important that 
macros do not have any other side effects beyond generating their text."

So this would break the no side effect rule. However, the idempotent design 
means that subsequent calls to this macro should not have any side effects. 

Will this potentially break stuff in unknown ways? I would also like to 
know if there are other methods to achieve the same tasks in JS.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/61d60848-818b-45a1-8554-7de4e91a92e2n%40googlegroups.com.

Reply via email to