diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js new file mode 100644 index 000000000..31f53a577 --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js @@ -0,0 +1,64 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js +type: application/javascript +module-type: wikirule + +Wiki text rule for inline 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"; + +exports.name = "filteredtransclude"; +exports.types = {inline: true}; + +exports.init = function(parser) { + this.parser = parser; + // Regexp to match + this.matchRegExp = /\{\{\{([^\{\}\|]+)(?:\|([^\|\{\}]+))?(?:\|\|([^\|\{\}]+))?\}\}([^\}]*)\}(?:\.(\S+))?/mg; +}; + +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], + template = this.match[3], + style = this.match[4], + classes = this.match[5]; + // Return the list widget + var node = { + type: "widget", + tag: "list", + attributes: { + filter: {type: "string", value: filter} + } + }; + 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) { + node.attributes["itemClass"] = {type: "string", value: classes.split(".").join(" ")}; + } + return [node]; +}; + +})(); diff --git a/core/modules/widgets/list/list.js b/core/modules/widgets/list/list.js index 441947172..8936c412f 100644 --- a/core/modules/widgets/list/list.js +++ b/core/modules/widgets/list/list.js @@ -55,7 +55,7 @@ exports.generateChildNodes = function() { var classes = ["tw-list-frame"]; this.children = this.renderer.renderTree.createRenderers(this.renderer.renderContext,[{ type: "element", - tag: "div", + tag: this.renderer.parseTreeNode.isBlock ? "div" : "span", attributes: { "class": {type: "string", value: classes.join(" ")} }, @@ -104,7 +104,7 @@ exports.createListElement = function(title) { // Return the list element return { type: "element", - tag: "div", + tag: this.renderer.parseTreeNode.isBlock ? "div" : "span", attributes: { "class": {type: "string", value: classes.join(" ")} }, diff --git a/core/templates/NewPageTemplate.tid b/core/templates/NewPageTemplate.tid index 1d0eb8268..b5394aaaf 100644 --- a/core/templates/NewPageTemplate.tid +++ b/core/templates/NewPageTemplate.tid @@ -14,6 +14,8 @@ New paragraph *.disabled Is a * List!! +An inline {{{ [tag[docs]tag[introduction]sort[title]] }}}.anotherClassy yes it is! + {{{ [tag[docs]tag[introduction]sort[title]] ||$:/templates/NewViewTemplate}}}.anotherClassy <>