diff --git a/core/modules/macros/uniquetitle.js b/core/modules/macros/uniquetitle.js new file mode 100644 index 000000000..8531d1ce7 --- /dev/null +++ b/core/modules/macros/uniquetitle.js @@ -0,0 +1,34 @@ +/*\ +title: $:/core/modules/macros/unusedtitle.js +type: application/javascript +module-type: macro +Macro to return a new title that is unused in the wiki. It can be given a name as a base. +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Information about this macro +*/ + +exports.name = "unusedtitle"; + +exports.params = [ + {name: "baseName"}, + {name: "options"} +]; + +/* +Run the macro +*/ +exports.run = function(baseName, options) { + if(!baseName) { + baseName = $tw.language.getString("DefaultNewTiddlerTitle"); + } + return this.wiki.generateNewTitle(baseName, options); +}; + +})(); diff --git a/editions/tw5.com/tiddlers/macros/UnusedTitleMacro.tid b/editions/tw5.com/tiddlers/macros/UnusedTitleMacro.tid new file mode 100644 index 000000000..39fdacf93 --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/UnusedTitleMacro.tid @@ -0,0 +1,16 @@ + +caption: unusedtitle +tags: Macros [[Core Macros]] +title: unusedtitle Macro +type: text/vnd.tiddlywiki + +The <<.def unusedtitle>> [[macro|Macros]] returns an unused title. Optionally you can provide a base title to generate the new title. + +It uses the same method as the create new tiddler button, a number is appended to the end of the base name. + +!! Parameters + +;baseName +: A string specifying the desired base name, defaulting to `New Tiddler` + +<<.macro-examples "unusedtitle">> diff --git a/editions/tw5.com/tiddlers/macros/examples/unusedtitle.tid b/editions/tw5.com/tiddlers/macros/examples/unusedtitle.tid new file mode 100644 index 000000000..0389d2d67 --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/examples/unusedtitle.tid @@ -0,0 +1,7 @@ +tags: [[unusedtitle Macro]] [[Macro Examples]] +title: unusedtitle Macro (Examples) +type: text/vnd.tiddlywiki + +<$macrocall $name=".example" n="1" eg="""<>"""/> +<$macrocall $name=".example" n="2" eg="""<>"""/> +<$macrocall $name=".example" n="3" eg="""<>"""/>