mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-14 13:51:24 +00:00
Add unusedtitle macro (#3880)
* Add uniquetitle macro This macro is a wrapper on the $tw.wiki.generateNewTitle function to return a unique name, it has been requested multiple times in the forums. * Add documentation tiddler for uniquetitle macro * Add uniquetitle macro examples * Change name from uniquetitle to unusedtitle for clarity The title isn't unique, just not currently used in the wiki. * Update uniquetitle to unusedtitle * Change uniquetitle to unusedtitle * Fix a typo
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user