From 2e0c119d5b7cfb29ad799e35fe703413acf157e3 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 17 Apr 2017 17:04:15 +0100 Subject: [PATCH] Add Tiddler.getFieldStrings() method --- core/modules/tiddler.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/modules/tiddler.js b/core/modules/tiddler.js index e67bab2cc..e3382af4a 100644 --- a/core/modules/tiddler.js +++ b/core/modules/tiddler.js @@ -39,6 +39,24 @@ exports.getFieldString = function(field) { } }; +/* +Get all the fields as a hashmap of strings. Options: + exclude: an array of field names to exclude +*/ +exports.getFieldStrings = function(options) { + options = options || {}; + var exclude = options.exclude || []; + var fields = {}; + for(var field in this.fields) { + if($tw.utils.hop(this.fields,field)) { + if(exclude.indexOf(field) === -1) { + fields[field] = this.getFieldString(field); + } + } + } + return fields; +}; + /* Get all the fields as a name:value block. Options: exclude: an array of field names to exclude