> Any idea for simplifying this script ?

* use regexp to match-and-replace section content
* match any specified section name
* preserve author/date (if "minor changes" is set)
* preserve existing tags and fields
* force refresh of currently displayed tiddler

<script label="change">
        var t=store.getTiddler(story.findContainingTiddler(place).getAttribute
("tiddler"));
        var s="section1";
        var c="content updated - "+new Date().toString();
        var p=new RegExp("(.*!{1,6}"+s+"\\n).*((?:\\n!{1,6}|$).*)");
        var r="$"+"1"+c+"$"+"2";
        var who =config.options.chkForceMinorUpdate?
t.modifier:config.options.txtUserName;
        var when=config.options.chkForceMinorUpdate?t.modified:new Date();
        store.saveTiddler(t.title,t.title,t.text.replace
(p,r),who,when,t.tags,t.fields);
        story.refreshTiddler(t.title,null,true);
</script>

Notes:
* in above code, new content includes current date/time stamp for demo
purposes only
* the $1 and $2 in the regexp replacement text has been written as
$"+"1 and $"+"2 so that those sequences are not replaced if you
tranclude this script via <<tiddler ... with: ...>>.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to