2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/tiddler.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: tiddlermethod
|
|
|
|
|
|
|
|
Extension methods for the $tw.Tiddler object
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2012-05-04 17:49:04 +00:00
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
2012-04-30 11:23:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.hasTag = function(tag) {
|
|
|
|
return this.fields.tags && this.fields.tags.indexOf(tag) !== -1;
|
|
|
|
};
|
|
|
|
|
2012-10-16 18:12:09 +00:00
|
|
|
exports.hasField = function(field) {
|
|
|
|
return $tw.utils.hop(this.fields,field);
|
|
|
|
};
|
|
|
|
|
2012-04-30 11:23:03 +00:00
|
|
|
exports.getFieldString = function(field) {
|
|
|
|
var value = this.fields[field];
|
|
|
|
// Check for a missing field
|
|
|
|
if(value === undefined) {
|
|
|
|
return undefined;
|
|
|
|
}
|
2012-08-03 14:09:48 +00:00
|
|
|
// Parse the field with the associated module (if any)
|
|
|
|
var fieldModule = $tw.Tiddler.fieldModules[field];
|
|
|
|
if(fieldModule) {
|
|
|
|
return fieldModule.stringify.call(this,value);
|
2012-04-30 11:23:03 +00:00
|
|
|
} else {
|
|
|
|
return value.toString();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|