From f16d1832aae9a7ce71dea78b16c11afaf673acf2 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 8 Sep 2014 15:06:48 +0100 Subject: [PATCH] Add dumpvariables macro --- core/modules/macros/dumpvariables.js | 41 +++++++++++++++++++ .../tw5.com/tiddlers/macros/dumpvariables.tid | 27 ++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 core/modules/macros/dumpvariables.js create mode 100644 editions/tw5.com/tiddlers/macros/dumpvariables.tid diff --git a/core/modules/macros/dumpvariables.js b/core/modules/macros/dumpvariables.js new file mode 100644 index 000000000..248beae96 --- /dev/null +++ b/core/modules/macros/dumpvariables.js @@ -0,0 +1,41 @@ +/*\ +title: $:/core/modules/macros/dumpvariables.js +type: application/javascript +module-type: macro + +Macro to dump all active variable values + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Information about this macro +*/ + +exports.name = "dumpvariables"; + +exports.params = [ +]; + +/* +Run the macro +*/ +exports.run = function() { + var output = ["|!Variable |!Value |"], + variables = [], variable; + for(variable in this.variables) { + variables.push(variable); + } + variables.sort(); + for(var index=0; index>/> |") + } + return output.join("\n"); +}; + +})(); diff --git a/editions/tw5.com/tiddlers/macros/dumpvariables.tid b/editions/tw5.com/tiddlers/macros/dumpvariables.tid new file mode 100644 index 000000000..dc86ff458 --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/dumpvariables.tid @@ -0,0 +1,27 @@ +created: 20140908104107181 +modified: 20140908104107181 +tags: macros +title: DumpVariablesMacro +type: text/vnd.tiddlywiki + +The dumpvariables macro displays a table containing the values of all the variables defined at that location in the widget tree. It can be useful for exploring the mechanisms of TiddlyWiki and for debugging. + +! Parameters + +The dumpvariables macro does not require any parameters + +! Examples + + +``` +<> +``` + +Returns: + +<> + +The results returned by the dumpvariables macro will depend upon where it is used. + +Note that the values displayed for macros are displayed with all the parameters and variable subsitutions set to an empty string. So, a macro defined as `\define myMacro(text) ''$text$''` will display as `''''`. +