1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-07-05 03:22:51 +00:00

Render command: verbose mode should print title before rendering

Fixes #6067
This commit is contained in:
jeremy@jermolene.com 2021-09-24 18:40:34 +01:00
parent ebf563ac70
commit e577cf7302

View File

@ -8,24 +8,24 @@ Render individual tiddlers and save the results to the specified files
\*/ \*/
(function(){ (function(){
/*jslint node: true, browser: true */ /*jslint node: true, browser: true */
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
var widget = require("$:/core/modules/widgets/widget.js"); var widget = require("$:/core/modules/widgets/widget.js");
exports.info = { exports.info = {
name: "render", name: "render",
synchronous: true synchronous: true
}; };
var Command = function(params,commander,callback) { var Command = function(params,commander,callback) {
this.params = params; this.params = params;
this.commander = commander; this.commander = commander;
this.callback = callback; this.callback = callback;
}; };
Command.prototype.execute = function() { Command.prototype.execute = function() {
if(this.params.length < 1) { if(this.params.length < 1) {
return "Missing tiddler filter"; return "Missing tiddler filter";
} }
@ -45,21 +45,22 @@ Command.prototype.execute = function() {
variableList = variableList.slice(2); variableList = variableList.slice(2);
} }
$tw.utils.each(tiddlers,function(title) { $tw.utils.each(tiddlers,function(title) {
var parser = wiki.parseTiddler(template || title); var filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
var widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title})}),
container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent,
filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
if(self.commander.verbose) { if(self.commander.verbose) {
console.log("Rendering \"" + title + "\" to \"" + filepath + "\""); console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
} }
var parser = wiki.parseTiddler(template || title),
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title})}),
container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent;
$tw.utils.createFileDirectories(filepath); $tw.utils.createFileDirectories(filepath);
fs.writeFileSync(filepath,text,"utf8"); fs.writeFileSync(filepath,text,"utf8");
}); });
return null; return null;
}; };
exports.Command = Command; exports.Command = Command;
})();
})();