Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.