1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-10 07:43:49 +00:00

Fixed ordering of attributes in tiddler <DIV>s

To match the ordering produced by TiddlyWiki
This commit is contained in:
Jeremy Ruston 2011-12-03 13:01:24 +00:00
parent b07d518425
commit 6ef4fbf0ed

View File

@ -46,34 +46,39 @@ tiddlerOutput.outputTiddler = function(tid) {
Output a tiddler as an HTML <DIV> Output a tiddler as an HTML <DIV>
out - array to push the output strings out - array to push the output strings
tid - the tiddler to be output tid - the tiddler to be output
options - options: The fields are in the order title, creator, modifier, created, modified, tags, followed by any others
omitPrecedingLineFeed - determines if a linefeed is inserted between the <PRE> tag and the text
*/ */
tiddlerOutput.outputTiddlerDiv = function(tid) { tiddlerOutput.outputTiddlerDiv = function(tid) {
var result = [], var result = [],
outputAttribute = function(name,value) { attributes = {},
result.push(" " + name + "=\"" + value + "\""); outputAttribute = function(name,transform,dontDelete) {
if(name in attributes) {
var value = attributes[name];
if(transform)
value = transform(value);
result.push(" " + name + "=\"" + value + "\"");
if(!dontDelete) {
delete attributes[name];
}
}
}; };
result.push("<div");
for(var t in tid.fields) { for(var t in tid.fields) {
switch(t) { attributes[t] = tid.fields[t];
case "text": }
// Ignore the text field if(attributes.text) {
break; delete attributes.text;
case "tags": }
// Output tags as a list result.push("<div");
outputAttribute(t,tiddlerOutput.stringifyTags(tid.fields.tags)); // Output the standard attributes in the correct order
break; outputAttribute("title");
case "modified": outputAttribute("creator");
case "created": outputAttribute("modifier");
// Output dates in YYYYMMDDHHMMSS outputAttribute("created", function(v) {return utils.convertToYYYYMMDDHHMM(v)});
outputAttribute(t,utils.convertToYYYYMMDDHHMM(tid.fields[t])); outputAttribute("modified", function(v) {return utils.convertToYYYYMMDDHHMM(v)});
break; outputAttribute("tags", function(v) {return tiddlerOutput.stringifyTags(v)});
default: // Output any other attributes
// Output other attributes raw for(t in attributes) {
outputAttribute(t,tid.fields[t]); outputAttribute(t,null,true);
break;
}
} }
result.push(">\n<pre>"); result.push(">\n<pre>");
result.push(utils.htmlEncode(tid.fields.text)); result.push(utils.htmlEncode(tid.fields.text));