2012-12-23 10:37:18 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: wikirule
|
|
|
|
|
|
|
|
Wiki text rule for block-level filtered transclusion. For example:
|
|
|
|
|
|
|
|
```
|
|
|
|
{{{ [tag[docs]] }}}
|
|
|
|
{{{ [tag[docs]] |tooltip}}}
|
|
|
|
{{{ [tag[docs]] ||TemplateTitle}}}
|
|
|
|
{{{ [tag[docs]] |tooltip||TemplateTitle}}}
|
|
|
|
{{{ [tag[docs]] }}width:40;height:50;}.class.class
|
|
|
|
```
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2012-12-26 19:32:54 +00:00
|
|
|
exports.name = "filteredtranscludeblock";
|
2012-12-23 10:37:18 +00:00
|
|
|
exports.types = {block: true};
|
|
|
|
|
|
|
|
exports.init = function(parser) {
|
|
|
|
this.parser = parser;
|
|
|
|
// Regexp to match
|
2013-03-02 13:01:44 +00:00
|
|
|
this.matchRegExp = /\{\{\{([^\|]+?)(?:\|([^\|\{\}]+))?(?:\|\|([^\|\{\}]+))?\}\}([^\}]*)\}(?:\.(\S+))?(?:\r?\n|$)/mg;
|
2012-12-23 10:37:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.parse = function() {
|
|
|
|
// Move past the match
|
|
|
|
this.parser.pos = this.matchRegExp.lastIndex;
|
|
|
|
// Get the match details
|
|
|
|
var filter = this.match[1],
|
|
|
|
tooltip = this.match[2],
|
2012-12-26 19:32:54 +00:00
|
|
|
template = $tw.utils.trim(this.match[3]),
|
2012-12-23 10:37:18 +00:00
|
|
|
style = this.match[4],
|
|
|
|
classes = this.match[5];
|
|
|
|
// Return the list widget
|
|
|
|
var node = {
|
2014-05-14 07:51:08 +00:00
|
|
|
type: "list",
|
2012-12-23 10:37:18 +00:00
|
|
|
attributes: {
|
|
|
|
filter: {type: "string", value: filter}
|
|
|
|
},
|
|
|
|
isBlock: true
|
|
|
|
};
|
|
|
|
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};
|
|
|
|
}
|
|
|
|
if(classes) {
|
2014-08-30 19:44:26 +00:00
|
|
|
node.attributes.itemClass = {type: "string", value: classes.split(".").join(" ")};
|
2012-12-23 10:37:18 +00:00
|
|
|
}
|
|
|
|
return [node];
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|