Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
Created May 5, 2020 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbgutierrez/d658512c529e412f2c7f6dbbb104545e to your computer and use it in GitHub Desktop.
Save jbgutierrez/d658512c529e412f2c7f6dbbb104545e to your computer and use it in GitHub Desktop.
<script type="customer-template" include-category="NINO" exclude-category="ZAPATO">
<style>
#ninos-msg {
text-align: center;
}
</style>
<div>NINOS menos ZAPATOS</div>
</script>
<div id="customer-template"> </div>
<script type="text/javascript">
(function() {
var renderTemplate = function() {
var id = document.documentElement.getAttribute('id');
var templates = Array.from(document.querySelectorAll('script[type="customer-template"]'));
templates.forEach(function(template) {
var include = template.getAttribute('include-category');
if (include) {
var re = new RegExp(include);
if (!re.test(id)) return;
}
var exclude = template.getAttribute('exclude-category');
if (exclude) {
var re = new RegExp(exclude);
if (re.test(id)) return;
}
document.getElementById('customer-template').innerHTML = template.innerHTML;
});
}
document.addEventListener('DOMContentLoaded', function() {
renderTemplate();
var standard = <%- at('web') %>;
if (standard) {
var _require = window._zaraRequire || window.require || null;
_require(["plugins/router/engine"], (Router) => { Router.registerMiddleware("beforeShow", renderTemplate); });
}
});
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment