Last active
February 3, 2019 08:10
-
-
Save ervinne13/a06dd89f323b40f60502138b1a9e6031 to your computer and use it in GitHub Desktop.
Refactoring JavaScript: Separation of Concerns - Markup Code on JS Fix
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 src="js/tmpl.min.js"></script> | |
<script type="text/x-tmpl" id="tmpl-specific-widget-x"> | |
<div id="specific-widget-x" class="specific-widget-x"> | |
<h2>{%=o.title%}</h2> | |
<div class="specific-widget-x-body-classes"> | |
{%=o.text%} | |
</div> | |
</div> | |
</script> | |
<script type="text/javascript"> | |
let widgetData = { | |
title: "My Widget", | |
text: "JavaScript is Quirky", | |
}; | |
document.getElementById("widget-container").innerHTML = tmpl("tmpl-specific-widget-x", widgetData); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment