mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-02 17:00:45 +00:00
Add a function to check whether a tiddler has a given field
This commit is contained in:
parent
f0974740db
commit
a832338bb6
@ -92,7 +92,7 @@ Create the tiddler macro needed to represent a given tiddler
|
|||||||
exports.createListElementMacro = function(title) {
|
exports.createListElementMacro = function(title) {
|
||||||
// Check if the tiddler is a draft
|
// Check if the tiddler is a draft
|
||||||
var tiddler = this.wiki.getTiddler(title),
|
var tiddler = this.wiki.getTiddler(title),
|
||||||
draft = tiddler ? $tw.utils.hop(tiddler.fields,"draft-of") : false;
|
draft = tiddler ? tiddler.hasField("draft-of") : false;
|
||||||
// Figure out the template to use
|
// Figure out the template to use
|
||||||
var template = this.params.template,
|
var template = this.params.template,
|
||||||
templateText = this.params.templateText;
|
templateText = this.params.templateText;
|
||||||
|
@ -16,6 +16,10 @@ exports.hasTag = function(tag) {
|
|||||||
return this.fields.tags && this.fields.tags.indexOf(tag) !== -1;
|
return this.fields.tags && this.fields.tags.indexOf(tag) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.hasField = function(field) {
|
||||||
|
return $tw.utils.hop(this.fields,field);
|
||||||
|
};
|
||||||
|
|
||||||
exports.getFieldString = function(field) {
|
exports.getFieldString = function(field) {
|
||||||
var value = this.fields[field];
|
var value = this.fields[field];
|
||||||
// Check for a missing field
|
// Check for a missing field
|
||||||
|
Loading…
Reference in New Issue
Block a user