mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	Fixed view macro to check whether the tiddler exists
This commit is contained in:
		| @@ -18,9 +18,12 @@ exports.macro = { | ||||
| 		template: {byPos: 2, type: "text", optional: true} | ||||
| 	}, | ||||
| 	handler: function(type,tiddler,store,params) { | ||||
| 		var v = tiddler[params.field], | ||||
| 			encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;}; | ||||
| 		if(v) { | ||||
| 		var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;}; | ||||
| 		if(!tiddler) { | ||||
| 			return "{{** Missing tiddler **}}"; | ||||
| 		} else { | ||||
| 			var v = tiddler[params.field]; | ||||
| 			if(v !== undefined) { | ||||
| 				switch(params.format) { | ||||
| 					case "link": | ||||
| 						return store.renderMacro("link",type,tiddler,{target: v},encoder(v)); | ||||
| @@ -33,6 +36,7 @@ exports.macro = { | ||||
| 						return encoder(v); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return ""; | ||||
| 	} | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston