Add template syntax for transclusion

print-window-tiddler
Jeremy Ruston 2012-12-23 10:36:55 +00:00
rodzic 8ef3e59416
commit 05ccb85759
2 zmienionych plików z 18 dodań i 6 usunięć

Wyświetl plik

@ -8,6 +8,8 @@ Wiki text rule for block-level transclusion. For example:
```
{{MyTiddler}}
{{MyTiddler|tooltip}}
{{MyTiddler||TemplateTitle}}
{{MyTiddler|tooltip||TemplateTitle}}
{{MyTiddler}width:40;height:50;}.class.class
```
@ -24,7 +26,7 @@ exports.types = {block: true};
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /\{\{([^\{\}\|]+)(?:\|([^\{\}]+))?\}([^\}]*)\}(?:\.(\S+))?(?:\r?\n|$)/mg;
this.matchRegExp = /\{\{([^\{\}\|]+)(?:\|([^\|\{\}]+))?(?:\|\|([^\|\{\}]+))?\}([^\}]*)\}(?:\.(\S+))?(?:\r?\n|$)/mg;
};
exports.parse = function() {
@ -33,8 +35,9 @@ exports.parse = function() {
// Get the match details
var targetTitle = this.match[1],
tooltip = this.match[2],
style = this.match[3],
classes = this.match[4];
template = this.match[3],
style = this.match[4],
classes = this.match[5];
// Return the transclude widget
var node = {
type: "widget",
@ -47,6 +50,9 @@ exports.parse = function() {
if(tooltip) {
node.attributes.tooltip = {type: "string", value: tooltip};
}
if(template) {
node.attributes.template = {type: "string", value: template};
}
if(style) {
node.attributes.style = {type: "string", value: style};
}

Wyświetl plik

@ -8,6 +8,8 @@ Wiki text rule for inline-level transclusion. For example:
```
{{MyTiddler}}
{{MyTiddler|tooltip}}
{{MyTiddler||TemplateTitle}}
{{MyTiddler|tooltip||TemplateTitle}}
{{MyTiddler}width:40;height:50;}.class.class
```
@ -24,7 +26,7 @@ exports.types = {inline: true};
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /\{\{([^\{\}\|]+)(?:\|([^\{\}]+))?\}([^\}]*)\}(?:\.(\S+))?/mg;
this.matchRegExp = /\{\{([^\{\}\|]+)(?:\|([^\|\{\}]+))?(?:\|\|([^\|\{\}]+))?\}([^\}]*)\}(?:\.(\S+))?/mg;
};
exports.parse = function() {
@ -33,8 +35,9 @@ exports.parse = function() {
// Get the match details
var targetTitle = this.match[1],
tooltip = this.match[2],
style = this.match[3],
classes = this.match[4];
template = this.match[3],
style = this.match[4],
classes = this.match[5];
// Return the transclude widget
var node = {
type: "widget",
@ -46,6 +49,9 @@ exports.parse = function() {
if(tooltip) {
node.attributes.tooltip = {type: "string", value: tooltip};
}
if(template) {
node.attributes.template = {type: "string", value: template};
}
if(style) {
node.attributes.style = {type: "string", value: style};
}