Created
May 5, 2020 11:20
-
-
Save jbgutierrez/d658512c529e412f2c7f6dbbb104545e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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