Skip to content

Commit

Permalink
Merge pull request #10 from PublicisSapient/dependabot-fixes
Browse files Browse the repository at this point in the history
Dependabot fixes
  • Loading branch information
zoltan-dulac authored Oct 14, 2022
2 parents 570fe71 + 6037412 commit 46f3e3c
Show file tree
Hide file tree
Showing 4 changed files with 30,423 additions and 29,922 deletions.
1 change: 1 addition & 0 deletions css/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fieldset .legend,
[role="radiogroup"] .legend {
position: relative;
top: 1.5em;
width: 100%;
border-color: #aaaaaa;
font-weight: bold;
font-size: 1em;
Expand Down
52 changes: 52 additions & 0 deletions js/modules/es4/templify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable no-console */


class Templify {
constructor(element, props) {
this.props = props;
this.element = element;
this.className = 'flyout-menu';
this.contentToken = '${html:content}';
this.varRe = /\$\{[^}]*}/g;

element.innerHTML = this.renderContent(this.props.content);
}

renderContent(templates) {
const html = [];

if (templates) {
templates.forEach((template) => {
html.push(this.renderTemplate(template));
});
}

return html.join('');
}

renderTemplate(template) {
const { id, props, content } = template;
const $template = document.getElementById(id);
let html;

if ($template) {
const templateHTML = $template.innerHTML;
html = interpolate(templateHTML, props);
if (html.indexOf(this.contentToken) > -1) {
const contentHTML = this.renderContent(content);
html = html.replace(this.contentToken, contentHTML);
}

/* Let's remove all other variables that haven't been used. */
if (html.match(this.varRe) !== null) {
html = html.replace(this.varRe, '');
}
} else {
html = `%${id}%`;
}

return html;
}
}


Loading

0 comments on commit 46f3e3c

Please sign in to comment.