From 91e1a38db1e81b14881812c413f6bb820738666a Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 29 Nov 2012 18:34:27 +0000 Subject: [PATCH] Switched to use double curly braces for transclusion For compatbility with MediaWiki and other engines --- core/modules/macros/list/list.js | 11 ++++--- .../parsers/wikitextparser/rules/coderun.js | 2 +- .../wikitextparser/rules/transclude.js | 29 +++++++------------ core/templates/StaticContent.tid | 6 +++- core/templates/TagTemplate.tid | 11 ++++--- core/templates/ViewTemplate.tid | 2 +- editions/tw5.com/tiddlers/AllTiddlers.tid | 2 +- .../tiddlers/concepts/ShadowTiddlers.tid | 2 +- .../tw5.com/tiddlers/concepts/WikiText.tid | 7 ++--- .../tiddlers/samples/CecilyTemplate.tid | 2 +- .../tw5dropbox/appwiki/wiki/AllTiddlers.tid | 2 +- .../tw5dropbox/appwiki/wiki/PageTemplate.tid | 2 +- .../tw5dropbox/mainwiki/wiki/PageTemplate.tid | 2 +- .../tiddlers/TiddlyWiki5 for TiddlyWeb.tid | 4 +-- 14 files changed, 40 insertions(+), 44 deletions(-) diff --git a/core/modules/macros/list/list.js b/core/modules/macros/list/list.js index 70ed219f3..e78bd383f 100644 --- a/core/modules/macros/list/list.js +++ b/core/modules/macros/list/list.js @@ -26,7 +26,7 @@ exports.info = { listview: {byName: true, type: "text"}, itemClass: {byName: true, type: "text"}, map: {byName: true, type: "tiddler"}, - forceBlock: {ByName: true, type: "text"} // HACK: To be removed... + block: {ByName: true, type: "text"} // HACK: To be removed... } }; @@ -43,8 +43,8 @@ var typeMappings = { exports.executeMacro = function() { this.useBlock = this.isBlock; - if(this.hasParameter("forceBlock")) { - this.useBlock = true; + if(this.hasParameter("block")) { + this.useBlock = this.params.block === "yes"; } // Get the list of tiddlers object this.getTiddlerList(); @@ -154,7 +154,10 @@ exports.createListElementMacro = function(title) { if(!template) { if(this.content.length > 0) { // Use our content as the template - templateTree = this.content; + templateTree = []; + for(var t=0; t>) -(((My filter expression))) -(((My filter expression))(MyTemplate)) -(((My filter expression))Template <>) +{{MyTiddler}} +{{MyTiddler}{MyTemplate}} +{{MyTiddler}Template <>} }}} \*/ @@ -26,31 +23,25 @@ exports.name = "transclude"; exports.runParser = true; exports.blockParser = true; -exports.regExpString = "\\(\\((?:(?:[^\\(\\)]+)|(?:\\([^\\(\\)]+\\)))\\)(?:\\([^\\)]+\\)|(?:[^\\)]+))?\\)"; +exports.regExpString = "\\{\\{(?:(?:[^\\{\\}]+)|(?:\\{[^\\{\\}]+\\}))\\}(?:\\{[^\\}]+\\}|(?:[^\\}]+))?\\}"; exports.parse = function(match,isBlock) { - var regExp = /\(\((?:([^\(\)]+)|(?:\(([^\(\)]+)\)))\)(?:\(([^\)]+)\)|([^\)]+))?\)((?:\r?\n)?)/mg; + var regExp = /\{\{([^\{\}]+)\}(?:\{([^\}]+)\}|([^\}]+))?\}((?:\r?\n)?)/mg; regExp.lastIndex = this.pos; match = regExp.exec(this.source); if(match && match.index === this.pos) { this.pos = match.index + match[0].length; var macro, params = {}, parseTree; - // Check if it is a single tiddler if(match[1]) { - macro = "tiddler"; params.target = match[1]; - } else { - // Else it is a filter - macro = "list"; - params.filter = match[2]; + } + if(match[2]) { + params.template = match[2]; } if(match[3]) { - params.template = match[3]; + parseTree = this.wiki.parseText("text/vnd.tiddlywiki",match[3]).tree; } - if(match[4]) { - parseTree = this.wiki.parseText("text/vnd.tiddlywiki",match[4]).tree; - } - return [$tw.Tree.Macro(macro,{ + return [$tw.Tree.Macro("tiddler",{ srcParams: params, wiki: this.wiki, content: parseTree diff --git a/core/templates/StaticContent.tid b/core/templates/StaticContent.tid index 1c89eab32..eebc6d0ed 100644 --- a/core/templates/StaticContent.tid +++ b/core/templates/StaticContent.tid @@ -2,4 +2,8 @@ title: $:/templates/StaticContent type: text/vnd.tiddlywiki <> -((( [!is[shadow]sort[title]] ))
<>
) +<< + +
<>
+ +>> diff --git a/core/templates/TagTemplate.tid b/core/templates/TagTemplate.tid index 7067fda24..874da32ef 100644 --- a/core/templates/TagTemplate.tid +++ b/core/templates/TagTemplate.tid @@ -1,6 +1,6 @@ title: $:/templates/TagTemplate -{{btn-invisible{ +{{btn-invisible tw-tag-button{ <