Created
March 3, 2012 22:56
-
-
Save stanpalatnik/1968827 to your computer and use it in GitHub Desktop.
Dust.js Client side
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
<html> | |
<head> | |
<script src="dust-full-0.3.0.min.js"></script> | |
<script type="text/javascript"> | |
//example showing client-side compiling and rendering | |
var compiled = dust.compile("Hello {name}!", "index"); | |
dust.loadSource(compiled); | |
dust.render("index", {name: "David"}, function(err, out) { | |
if(err != null) | |
alert("Error loading page"); | |
//assume we have jquery | |
$("#pageContainer").html(out); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="pageContainer"></div> | |
</body> | |
</html> |
This code is not correct. You must execute after html is loaded, using, for example, $(document).ready
This code is not correct, no? You must execute after html is loaded, using, for example, $(document).ready
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is not correct, no? You must execute after html is loaded, using, for example, $(document).ready
<title>Pruebas dustjs</title> <script src="core/library/dust/dust-full-1.1.1.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var compiled = dust.compile("Hello {name}!", "index"); dust.loadSource(compiled); dust.render("index", { name : "David" }, function(err, out) { if (err != null) { alert("Error loading page"); } $("#pageContainer").html(out); }); }); </script>