mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Switched to use double curly braces for transclusion
For compatbility with MediaWiki and other engines
This commit is contained in:
parent
6d09b2fb9c
commit
91e1a38db1
@ -26,7 +26,7 @@ exports.info = {
|
|||||||
listview: {byName: true, type: "text"},
|
listview: {byName: true, type: "text"},
|
||||||
itemClass: {byName: true, type: "text"},
|
itemClass: {byName: true, type: "text"},
|
||||||
map: {byName: true, type: "tiddler"},
|
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() {
|
exports.executeMacro = function() {
|
||||||
this.useBlock = this.isBlock;
|
this.useBlock = this.isBlock;
|
||||||
if(this.hasParameter("forceBlock")) {
|
if(this.hasParameter("block")) {
|
||||||
this.useBlock = true;
|
this.useBlock = this.params.block === "yes";
|
||||||
}
|
}
|
||||||
// Get the list of tiddlers object
|
// Get the list of tiddlers object
|
||||||
this.getTiddlerList();
|
this.getTiddlerList();
|
||||||
@ -154,7 +154,10 @@ exports.createListElementMacro = function(title) {
|
|||||||
if(!template) {
|
if(!template) {
|
||||||
if(this.content.length > 0) {
|
if(this.content.length > 0) {
|
||||||
// Use our content as the template
|
// 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 {
|
} else {
|
||||||
// Use default content
|
// Use default content
|
||||||
var defaultTemplate = "<<view title link>>";
|
var defaultTemplate = "<<view title link>>";
|
||||||
|
@ -6,7 +6,7 @@ module-type: wikitextrule
|
|||||||
Wiki text run rule for code runs. For example:
|
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`.
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
@ -6,12 +6,9 @@ module-type: wikitextrule
|
|||||||
Wiki text rule for transclusion. For example:
|
Wiki text rule for transclusion. For example:
|
||||||
|
|
||||||
{{{
|
{{{
|
||||||
((MyTiddler))
|
{{MyTiddler}}
|
||||||
((MyTiddler)(MyTemplate))
|
{{MyTiddler}{MyTemplate}}
|
||||||
((MyTiddler)Template <<view text>>)
|
{{MyTiddler}Template <<view text>>}
|
||||||
(((My filter expression)))
|
|
||||||
(((My filter expression))(MyTemplate))
|
|
||||||
(((My filter expression))Template <<view text>>)
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
@ -26,31 +23,25 @@ exports.name = "transclude";
|
|||||||
exports.runParser = true;
|
exports.runParser = true;
|
||||||
exports.blockParser = true;
|
exports.blockParser = true;
|
||||||
|
|
||||||
exports.regExpString = "\\(\\((?:(?:[^\\(\\)]+)|(?:\\([^\\(\\)]+\\)))\\)(?:\\([^\\)]+\\)|(?:[^\\)]+))?\\)";
|
exports.regExpString = "\\{\\{(?:(?:[^\\{\\}]+)|(?:\\{[^\\{\\}]+\\}))\\}(?:\\{[^\\}]+\\}|(?:[^\\}]+))?\\}";
|
||||||
|
|
||||||
exports.parse = function(match,isBlock) {
|
exports.parse = function(match,isBlock) {
|
||||||
var regExp = /\(\((?:([^\(\)]+)|(?:\(([^\(\)]+)\)))\)(?:\(([^\)]+)\)|([^\)]+))?\)((?:\r?\n)?)/mg;
|
var regExp = /\{\{([^\{\}]+)\}(?:\{([^\}]+)\}|([^\}]+))?\}((?:\r?\n)?)/mg;
|
||||||
regExp.lastIndex = this.pos;
|
regExp.lastIndex = this.pos;
|
||||||
match = regExp.exec(this.source);
|
match = regExp.exec(this.source);
|
||||||
if(match && match.index === this.pos) {
|
if(match && match.index === this.pos) {
|
||||||
this.pos = match.index + match[0].length;
|
this.pos = match.index + match[0].length;
|
||||||
var macro, params = {}, parseTree;
|
var macro, params = {}, parseTree;
|
||||||
// Check if it is a single tiddler
|
|
||||||
if(match[1]) {
|
if(match[1]) {
|
||||||
macro = "tiddler";
|
|
||||||
params.target = match[1];
|
params.target = match[1];
|
||||||
} else {
|
}
|
||||||
// Else it is a filter
|
if(match[2]) {
|
||||||
macro = "list";
|
params.template = match[2];
|
||||||
params.filter = match[2];
|
|
||||||
}
|
}
|
||||||
if(match[3]) {
|
if(match[3]) {
|
||||||
params.template = match[3];
|
parseTree = this.wiki.parseText("text/vnd.tiddlywiki",match[3]).tree;
|
||||||
}
|
}
|
||||||
if(match[4]) {
|
return [$tw.Tree.Macro("tiddler",{
|
||||||
parseTree = this.wiki.parseText("text/vnd.tiddlywiki",match[4]).tree;
|
|
||||||
}
|
|
||||||
return [$tw.Tree.Macro(macro,{
|
|
||||||
srcParams: params,
|
srcParams: params,
|
||||||
wiki: this.wiki,
|
wiki: this.wiki,
|
||||||
content: parseTree
|
content: parseTree
|
||||||
|
@ -2,4 +2,8 @@ title: $:/templates/StaticContent
|
|||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
<<! For Google, and people without JavaScript >>
|
<<! 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>
|
||||||
|
|
||||||
|
>>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
title: $:/templates/TagTemplate
|
title: $:/templates/TagTemplate
|
||||||
|
|
||||||
{{btn-invisible{
|
{{btn-invisible tw-tag-button{
|
||||||
<<button popup:"$:/temp/TagDropDownLocation" qualifyTiddlerTitles:yes><
|
<<button popup:"$:/temp/TagDropDownLocation" qualifyTiddlerTitles:yes><
|
||||||
{{label{
|
{{label{
|
||||||
<<color background:yes default:#aaa><
|
<<color background:yes default:#aaa><
|
||||||
@ -16,13 +16,12 @@ title: $:/templates/TagTemplate
|
|||||||
{{dropdown-menu{
|
{{dropdown-menu{
|
||||||
|
|
||||||
* <<view title link>>
|
* <<view title link>>
|
||||||
*{{divider}}
|
*.divider
|
||||||
|
* <<list filter:"[is[current]tagging[]]"><
|
||||||
|
|
||||||
* (((
|
<li><<view title link>></li>
|
||||||
|
|
||||||
[is[current]tagging[]]
|
>>
|
||||||
|
|
||||||
)) <li><<view title link>></li> )
|
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ modifier: JeremyRuston
|
|||||||
>>
|
>>
|
||||||
|
|
||||||
{{tw-tags-wrapper{
|
{{tw-tags-wrapper{
|
||||||
((([is[current]tags[]]))($:/templates/TagTemplate))
|
<<list filter:[is[current]tags[]] template:"$:/templates/TagTemplate" block:no>>
|
||||||
}}}
|
}}}
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<<view text wikified>>
|
<<view text wikified>>
|
||||||
|
@ -3,4 +3,4 @@ tags: navigation
|
|||||||
|
|
||||||
Current tiddlers:
|
Current tiddlers:
|
||||||
|
|
||||||
((( [!is[shadow]sort[title]] )) <div><<view title link>></div> )
|
<<list all>>
|
||||||
|
@ -7,4 +7,4 @@ Thus, even an apparently empty TiddlyWiki actually contains dozens of tiddlers t
|
|||||||
|
|
||||||
The current shadow tiddlers are:
|
The current shadow tiddlers are:
|
||||||
|
|
||||||
((( [is[shadow]sort[title]] )) <div><<view title link>></div> )
|
<<list shadows>>
|
||||||
|
@ -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:
|
You can incorporate the content of one tiddler within another using the transclusion notation:
|
||||||
|
|
||||||
* `((JeremyRuston))` transcludes a single tiddler
|
* `{{JeremyRuston}}` transcludes a single tiddler
|
||||||
* `((( [tag[docs]] )))`, with triple parenthesis, transcludes all the tiddlers that match a [[TiddlerFilter|TiddlerFilters]]
|
|
||||||
|
|
||||||
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.
|
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} <<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}{MyTemplate}}` renders the tiddler `MyTiddler` through the template `MyTemplate`
|
||||||
|
|
||||||
! Lists
|
! Lists
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ title: CecilyTemplate
|
|||||||
<<view modifier link>> <<view modified date>>
|
<<view modifier link>> <<view modified date>>
|
||||||
</div>
|
</div>
|
||||||
{{tw-tags-wrapper{
|
{{tw-tags-wrapper{
|
||||||
((([is[current]tags[]]))($:/templates/TagTemplate))
|
{{{[is[current]tags[]]}}{$:/templates/TagTemplate}}
|
||||||
}}}
|
}}}
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<<view text wikified>>
|
<<view text wikified>>
|
||||||
|
@ -3,4 +3,4 @@ tags: navigation
|
|||||||
|
|
||||||
Current tiddlers:
|
Current tiddlers:
|
||||||
|
|
||||||
((( [!is[shadow]sort[title]] )) <div><<view title link>></div> )
|
{{{ [!is[shadow]sort[title]] }} <div><<view title link>></div> }
|
||||||
|
@ -10,7 +10,7 @@ title: $:/templates/PageTemplate
|
|||||||
{{nav{
|
{{nav{
|
||||||
|
|
||||||
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:no>< <<dropbox.login>< Log me in >> >>
|
<<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 -->
|
<!-- Navigation menu -->
|
||||||
* HelloThere
|
* HelloThere
|
||||||
|
@ -10,7 +10,7 @@ title: $:/templates/PageTemplate
|
|||||||
{{nav{
|
{{nav{
|
||||||
|
|
||||||
<<reveal state:[[$:/plugins/dropbox/IsLoggedIn]] type:match text:no>< <<dropbox.login>< Log me in >> >>
|
<<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]]
|
[[App|TiddlyWiki5 in the Sky with Dropbox]]
|
||||||
|
|
||||||
|
@ -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}}
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
Loading…
Reference in New Issue
Block a user