Special treatment so that text reference to title field works for missing tiddlers

The title field is the one field that we know for missing tiddlers.

This is needed in a subsequent commit of viewswitcher.
This commit is contained in:
Jeremy Ruston 2013-07-08 15:16:55 +01:00
parent 53ead15273
commit 1304bfd0d4
1 changed files with 3 additions and 1 deletions

View File

@ -36,7 +36,9 @@ exports.getTextReference = function(textRef,defaultText,currTiddlerTitle) {
title = tr.title || currTiddlerTitle;
if(tr.field) {
var tiddler = this.getTiddler(title);
if(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) {
if(tr.field === "title") { // Special case so we can return the title of a non-existent tiddler
return title;
} else if(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) {
return tiddler.getFieldString(tr.field);
} else {
return defaultText;