I just created a macro which allows to transclude a tiddler(section) and
display it unwikified.
I found this helpful for accepting user input using the "EditSection"
plugin. As this input shouldn't be wikified in my case, all other tricks I
tried had disadvantages.
So with this macro, I can easily write
<<unwikified [[mytiddler##section]]>>
and get the tiddler(section) properly displayed inside a <pre> block.
I took most of the code from tiddlyTools core tweaks to the <<tiddler>>
macro. So <<unwikified>> also supports the "if:" parameter, but not the
"with:" parameter (but maybe that would also be a good idea?).
Could somene with more experience please take a look and give feedback, as
this is my first attempt for a macro?
//{{{
config.macros.unwikified= {};
config.macros.unwikified.handler = function
(place,macroName,params,wikifier,paramString,tiddler){
// this will run when macro is called from a tiddler
params = paramString.parseParams("name",null,true,false,true);
if (!getParam(params,'if',true)) return;
var names = params[0]["name"];
var tiddlerName = names[0];
var className = names[1] || null;
var wrapper = createTiddlyElement(place,"pre",null,className);
wrapper.setAttribute("refresh","unwikified");
wrapper.setAttribute("tiddler",tiddlerName);
config.refreshers.unwikified(wrapper,[tiddlerName.replace(/##.*/,'')]);
}
config.refreshers.unwikified= function(e,changeList) {
var title = e.getAttribute("tiddler");
var force = e.getAttribute("force");
var args = e.getAttribute("args");
if(force != null || changeList == null ||
changeList.indexOf(title.replace(/##.*/,'')) != -1) {
removeChildren(e);
var text = store.getTiddlerText(title); if (!text) return;
createTiddlyText(e, text);
return true;
}
else {
return false;
}
};
//}}}
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.