Hi,

At last I've found a way :

1 - define a macro that subsitutes the variables :

exports.name = "testMacro3";

exports.params = [
{ name: "title" }
];

/*
Run the macro
*/
exports.run = function(title) {
        var template = this.wiki.getTiddlerAsJson(title);
        return this.substituteVariableReferences(template);
};


2 - then create the navigator handler for the 
"tw-new-tiddler-with-skeleton" :

NavigatorWidget.prototype.handleNewTiddlerFromSkeletonEvent = 
function(event) {
    var skeletonClone = JSON.parse(event.param);
    var basetitle = skeletonClone.title;
    var title = basetitle;
    for(var t=1; this.wiki.tiddlerExists(title); t++) {
        title = basetitle + " " + t;
    }
    skeletonClone.title = title;
    var created = this.wiki.getCreationFields();
    for(var creationField in created) {
        skeletonClone[creationField] = created[creationField];
    }
    var modified = this.wiki.getModificationFields();
    for(var modificationField in modified) {
        skeletonClone[modificationField] = modified[modificationField];
    }
    this.wiki.addTiddler(skeletonClone);
//    this.dispatchEvent({type: "tw-edit-tiddler", tiddlerTitle: title});
    return false;
};


3 - call the message this way :

<$set name="a" value="tag1">
<$set name="b" value="World !">
<$set name="c" value="fieldvalue">
<$button message="tw-new-tiddler-from-skeleton" param=<<testMacro3 
"skel">>>bouton</$button>
</$set></$set></$set>

4- It works, but as it's not very elegant : REVERT to $newtiddler !!!

FrD


Le samedi 19 avril 2014 21:34:56 UTC+2, FrD a écrit :
>
> Hi,
>
> After a quick look at how variables are substitued, I think I'll give up 
> with my idea and use the $newtiddler widget !
>
> Thanks
>
> FrD
>
>

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to