2019-03-26 21:57:58 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/macros/unusedtitle.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: macro
|
2021-05-02 18:26:50 +00:00
|
|
|
|
2019-03-26 21:57:58 +00:00
|
|
|
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";
|
|
|
|
|
|
|
|
exports.name = "unusedtitle";
|
|
|
|
|
|
|
|
exports.params = [
|
|
|
|
{name: "baseName"},
|
2021-05-02 18:26:50 +00:00
|
|
|
{name: "separator"},
|
|
|
|
{name: "template"}
|
2019-03-26 21:57:58 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/*
|
|
|
|
Run the macro
|
|
|
|
*/
|
2021-05-02 18:26:50 +00:00
|
|
|
exports.run = function(baseName,separator,template) {
|
|
|
|
separator = separator || " ";
|
2019-03-26 21:57:58 +00:00
|
|
|
if(!baseName) {
|
|
|
|
baseName = $tw.language.getString("DefaultNewTiddlerTitle");
|
|
|
|
}
|
2021-05-02 18:26:50 +00:00
|
|
|
// $tw.wiki.generateNewTitle = function(baseTitle,options)
|
|
|
|
// options.prefix must be a string!
|
|
|
|
return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template});
|
2019-03-26 21:57:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|