mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 10:37:20 +00:00
daff9c10f3
"Plugins" are bundles of tiddlers managed as one, "modules" are JavaScript tiddlers with a module type identifying when and how they should be executed.
35 lines
720 B
JavaScript
35 lines
720 B
JavaScript
/*\
|
|
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 module (if any)
|
|
var fieldModule = $tw.Tiddler.fieldModules[field];
|
|
if(fieldModule) {
|
|
return fieldModule.stringify.call(this,value);
|
|
} else {
|
|
return value.toString();
|
|
}
|
|
};
|
|
|
|
})();
|