mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-08-29 06:08:54 +00:00
Support a class to be automatically added to transformed elements
This commit is contained in:
@@ -46,6 +46,10 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
|
||||
var mappedTag = this.getVariable("tv-map-" + this.tag);
|
||||
if(mappedTag) {
|
||||
this.tag = mappedTag.trim();
|
||||
var mappedClass = this.getVariable("tv-map-" + this.tag + "-class");
|
||||
if(mappedClass) {
|
||||
this.setAttribute("class",mappedClass.trim() + (this.getAttribute("class") ? " " + this.getAttribute("class") : ""));
|
||||
}
|
||||
}
|
||||
// Select the namespace for the tag
|
||||
var XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml",
|
||||
|
||||
@@ -7,12 +7,13 @@ title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<!-- Map <p> to <div> -->
|
||||
<!-- Map <p> to <div>, adding the class my-class -->
|
||||
\define tv-map-p() div
|
||||
\define tv-map-p-class() my-class
|
||||
|
||||
This is a paragraph
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<div>This is a paragraph</div>
|
||||
<div class="my-class">This is a paragraph</div>
|
||||
Reference in New Issue
Block a user