1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-01 16:13:00 +00:00

Part two of turning the rabbit hole inside out

This commit is contained in:
Jeremy Ruston
2012-05-05 22:57:21 +01:00
parent ee6d7b5cc5
commit 9465da4335
128 changed files with 0 additions and 0 deletions

34
core/modules/tiddler.js Normal file
View File

@@ -0,0 +1,34 @@
/*\
title: $:/core/modules/tiddler.js
type: application/javascript
module-type: tiddlermethod
Extension methods for the $tw.Tiddler object
\*/
(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.getFieldString = function(field) {
var value = this.fields[field];
// Check for a missing field
if(value === undefined) {
return undefined;
}
// Parse the field with the associated plugin (if any)
var fieldPlugin = $tw.Tiddler.fieldPlugins[field];
if(fieldPlugin) {
return fieldPlugin.stringify.call(this,value);
} else {
return value.toString();
}
};
})();