Hi guys,
Leo, thanks ;)
Stephan, although what you are doing is similar, "my" case is actually
simpler, as we can escape all those bad symbols before writing the
parameters as parts of DOM and then unescape them accordingly. So no need
of complicated parsing.
By the way, the fix is tested with PasteUpPlugin and works well. Yet as one
can see, it changes DOM which can be not desirable. I've found another way
to fix this, I like this one even more:
config.macros.tiddler.handler =
function(place,macroName,params,wikifier,paramString,tiddler) {
var allowEval = true;
var stack = config.macros.tiddler.tiddlerStack;
if(stack.length > 0 && config.evaluateMacroParameters == "system") {
// included tiddler and "system" evaluation required, so check
tiddler tagged appropriately
var title = stack[stack.length-1];
var pos = title.indexOf(config.textPrimitives.sectionSeparator);
if(pos != -1)
title = title.substr(0,pos); // get the base tiddler title
var t = store.getTiddler(title);
if(!t || t.tags.indexOf("systemAllowEval") == -1)
allowEval = false;
}
params = paramString.parseParams("name",null,allowEval,false,true);
var names = params[0]["name"];
var tiddlerName = names[0];
var className = names[1] || null;
var args = params[0]["with"];
var wrapper = createTiddlyElement(place,"span",null,className,null,{
refresh: "content", tiddler: tiddlerName
});
if(args!==undefined) {
wrapper.setAttribute("args","[["+args.join("]] [[")+"]]");
*jQuery(wrapper).data("args", { args: args })*
}
this.transclude(wrapper,tiddlerName,args);
};
config.refreshers.content = function(e,changeList)
{
var title = e.getAttribute("tiddler");
var force = e.getAttribute("force");
*var args = jQuery(e).data("args") ? jQuery(e).data("args").args :
e.getAttribute("args");*
if(force != null || changeList == null || (changeList.indexOf &&
changeList.indexOf(title) != -1)) {
jQuery(e).empty();
config.macros.tiddler.transclude(e,title,args);
return true;
} else
return false;
};
In this approach, I use the jQuery.data method, which was introduced a
while ago (it is present in TW since 2.6.2). Also, less new code: just 1.5
lines. Works with PasteUpPlugin, too.
The fact that I can't create a plugin by hijacking core functions (
config.macros.tiddler.handler and config.refreshers.content -- instead of
overwriting) is painful. This makes it necessary to add
"|Requires|ParametricTransclusionFix|" to each plugin which hijacks
config.macros.tiddler.handler (like PasteUpPlugin), so I'm really
interested if this will go to the core. The fix is rather well-tested for
now.
Best regards,
Yakov.
пятница, 28 февраля 2014 г., 17:59:18 UTC+4 пользователь Stephan Hradek
написал:
>
> maybe you're also interested in this discussion:
> https://github.com/Jermolene/TiddlyWiki5/issues/260
>
> It#s mainly about TW5 but it's the same root cause.
>
--
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.
For more options, visit https://groups.google.com/d/optout.