1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 00:50:28 +00:00

Switched to use double curly braces for transclusion

For compatbility with MediaWiki and other engines
This commit is contained in:
Jeremy Ruston 2012-11-29 18:34:27 +00:00
parent 6d09b2fb9c
commit 91e1a38db1
14 changed files with 40 additions and 44 deletions

View File

@ -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<this.content.length; t++) {
templateTree.push(this.content[t].clone());
}
} else {
// Use default content
var defaultTemplate = "<<view title link>>";

View File

@ -6,7 +6,7 @@ module-type: wikitextrule
Wiki text run rule for code runs. For example:
{{{
This is a {{{code run}} and `so is this`.
This is a {{{code run}}} and `so is this`.
}}}
\*/

View File

@ -6,12 +6,9 @@ module-type: wikitextrule
Wiki text rule for transclusion. For example:
{{{
((MyTiddler))
((MyTiddler)(MyTemplate))
((MyTiddler)Template <<view text>>)
(((My filter expression)))
(((My filter expression))(MyTemplate))
(((My filter expression))Template <<view text>>)
{{MyTiddler}}
{{MyTiddler}{MyTemplate}}
{{MyTiddler}Template <<view text>>}
}}}
\*/
@ -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

View File

@ -2,4 +2,8 @@ title: $:/templates/StaticContent
type: text/vnd.tiddlywiki
<<! For Google, and people without JavaScript >>
((( [!is[shadow]sort[title]] )) <div><<view title text>></div> )
<<list filter:[!is[shadow]sort[title]]><
<div><<view title text>></div>
>>

View File

@ -1,6 +1,6 @@
title: $:/templates/TagTemplate
{{btn-invisible{
{{btn-invisible tw-tag-button{
<<button popup:"$:/temp/TagDropDownLocation" qualifyTiddlerTitles:yes><
{{label{
<<color background:yes default:#aaa><
@ -16,13 +16,12 @@ title: $:/templates/TagTemplate
{{dropdown-menu{
* <<view title link>>
*{{divider}}
*.divider
* <<list filter:"[is[current]tagging[]]"><
* (((
<li><<view title link>></li>
[is[current]tagging[]]
)) <li><<view title link>></li> )
>>
}}}

View File

@ -24,7 +24,7 @@ modifier: JeremyRuston
>>
{{tw-tags-wrapper{
((([is[current]tags[]]))($:/templates/TagTemplate))
<<list filter:[is[current]tags[]] template:"$:/templates/TagTemplate" block:no>>
}}}
<div class="body">
<<view text wikified>>

View File

@ -3,4 +3,4 @@ tags: navigation
Current tiddlers:
((( [!is[shadow]sort[title]] )) <div><<view title link>></div> )
<<list all>>

View File

@ -7,4 +7,4 @@ Thus, even an apparently empty TiddlyWiki actually contains dozens of tiddlers t
The current shadow tiddlers are:
((( [is[shadow]sort[title]] )) <div><<view title link>></div> )
<<list shadows>>

View File

@ -77,13 +77,12 @@ You can also use `{{{` to mark code blocks:
You can incorporate the content of one tiddler within another using the transclusion notation:
* `((JeremyRuston))` transcludes a single tiddler
* `((( [tag[docs]] )))`, with triple parenthesis, transcludes all the tiddlers that match a [[TiddlerFilter|TiddlerFilters]]
* `{{JeremyRuston}}` transcludes a single tiddler
A template can also be specified, in which case the tiddler(s) are rendered through that [[TiddlerTemplate|TiddlerTemplates]]. Templates can either be specified directly or instead a tiddler can be specified from which the template is extracted.
* `((MyTiddler) <<view title>> by <<view modified>>)` renders the tiddler `MyTiddler` through a template that will yield `MyTiddler by JeremyRuston`, if the `modified` field is set to "JeremyRuston"
* `((MyTiddler)(MyTemplate))` renders the tiddler `MyTiddler` through the template `MyTemplate`
* `{{MyTiddler} <<view title>> by <<view modified>>}` renders the tiddler `MyTiddler` through a template that will yield `MyTiddler by JeremyRuston`, if the `modified` field is set to "JeremyRuston"
* `{{MyTiddler}{MyTemplate}}` renders the tiddler `MyTiddler` through the template `MyTemplate`
! Lists

View File

@ -8,7 +8,7 @@ title: CecilyTemplate
<<view modifier link>> <<view modified date>>
</div>
{{tw-tags-wrapper{
((([is[current]tags[]]))($:/templates/TagTemplate))
{{{[is[current]tags[]]}}{$:/templates/TagTemplate}}
}}}
<div class="body">
<<view text wikified>>

View File

@ -3,4 +3,4 @@ tags: navigation
Current tiddlers:
((( [!is[shadow]sort[title]] )) <div><<view title link>></div> )
{{{ [!is[shadow]sort[title]] }} <div><<view title link>></div> }

View File

@ -10,7 +10,7 @@ title: $:/templates/PageTemplate
{{nav{
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:no>< <<dropbox.login>< Log me in >> >>
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:yes>< Logged in as (($:/plugins/dropbox/UserName)) - <<dropbox.logout>< Log me out >> >>
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:yes>< Logged in as {{$:/plugins/dropbox/UserName}} - <<dropbox.logout>< Log me out >> >>
<!-- Navigation menu -->
* HelloThere

View File

@ -10,7 +10,7 @@ title: $:/templates/PageTemplate
{{nav{
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:no>< <<dropbox.login>< Log me in >> >>
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:yes>< Logged in as (($:/plugins/dropbox/UserName)) - <<dropbox.logout>< Log me out >> >>
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:yes>< Logged in as {{$:/plugins/dropbox/UserName}} - <<dropbox.logout>< Log me out >> >>
[[App|TiddlyWiki5 in the Sky with Dropbox]]

View File

@ -16,9 +16,9 @@ To try it out, create a new space, include the space `tw5tiddlyweb`, and then vi
----
Current [[login status|$:/plugins/tiddlyweb/IsLoggedIn]]: (($:/plugins/tiddlyweb/IsLoggedIn))
Current [[login status|$:/plugins/tiddlyweb/IsLoggedIn]]: {{$:/plugins/tiddlyweb/IsLoggedIn}}
Current [[username|$:/plugins/tiddlyweb/UserName]]: (($:/plugins/tiddlyweb/UserName))
Current [[username|$:/plugins/tiddlyweb/UserName]]: {{$:/plugins/tiddlyweb/UserName}}
----