$(function() {
$('#btnGenerateHtmlMail').click(function(ev) {
var $report = $('#report');
convertCssToInlineStyle($report);
var reportHtml = $report.html();
reportHtml = reportHtml
/* remove class attribute */
.replace(/class=('|").*?\1/g, "")
/* remove id attribute */
.replace(/id=('|").*?\1/g, "")
/* remove attribute data-render-value but retains the value*/
.replace(/data-render-value=('|").*?\1/g, function replacer(match) {
return match.replace(/data-render-value=('|")/, "").replace(/('|")$/, "");
})
/* remove comments html */
.replace(/<!--.*?-->/g, "")
/* remove tab, enter and whitespace */
.replace(/\s\s+/g, ' ')
// ----->>> // esse é o meu caso de problema, nesse exemplo não da problema pois nnão há tags iguais dentro do tr, mas sei que isso seria um bug que quero resolver para tornar a ferramenta generica
.replace(/<(tr) data-remove="true".*?>.*?<\/\1>/g, function replacer(match) {
console.log(match);
return match.match(/{{.*?}}/g);
});
$('#result').text(reportHtml);
});
});
/* Metódos irrelevantes para o problema */
function getCssDeclared($elem) {
var sheets = document.styleSheets,
o = {};
for (var i in sheets) {
var rules = sheets[i].rules || sheets[i].cssRules;
for (var r in rules) {
if ($elem.is(rules[r].selectorText)) {
o = $.extend(o, css2json(rules[r].style), css2json($elem.attr('style')));
}
}
}
return o;
}
function css2json(css) {
var s = {};
if (!css)
return s;
if (css instanceof CSSStyleDeclaration) {
for (var i in css) {
if ((css[i]).toLowerCase) {
s[(css[i]).toLowerCase()] = (css[css[i]]);
}
}
} else if (typeof css == "string ") {
css = css.split("; ");
for (var i in css) {
var l = css[i].split(": ");
s[l[0].toLowerCase()] = (l[1]);
}
}
return s;
}
function convertCssToInlineStyle($root) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.