/*\ title: $:/core/modules/tiddler.js type: application/javascript module-type: tiddlermethod Extension methods for the $tw.Tiddler object (constructor and methods required at boot time are in boot/boot.js) \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.hasTag = function(tag) { return this.fields.tags && this.fields.tags.indexOf(tag) !== -1; }; exports.isPlugin = function() { return this.fields.type === "application/json" && this.hasField("plugin-type"); }; exports.isDraft = function() { return this.hasField("draft.of"); }; /* Get the value of a field as a list */ exports.getFieldList = function(field) { var value = this.fields[field]; // Check for a missing field if(value === undefined || value === null) { return []; } return $tw.utils.parseStringArray(value); }; /* Get all the fields as a name:value block. Options: exclude: an array of field names to exclude */ exports.getFieldStringBlock = function(options) { options = options || {}; var exclude = options.exclude || [], fields = Object.keys(this.fields).sort(), result = []; for(var t=0; t