mirror of
https://github.com/S2-/ejs-render-remote
synced 2025-08-02 04:30:04 +02:00
add an example
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>ejs-render-remote example</h1>
|
<h1>ejs-render-remote example</h1>
|
||||||
<p class="hello"></p>
|
<p class="hello"></p>
|
||||||
|
<div class="sometext"></div>
|
||||||
|
|
||||||
<script src="jquery.min.js"></script>
|
<script src="jquery.min.js"></script>
|
||||||
<script src="ejs.min.js"></script>
|
<script src="ejs.min.js"></script>
|
||||||
@@ -18,6 +19,14 @@
|
|||||||
<script>
|
<script>
|
||||||
//render the template
|
//render the template
|
||||||
$('.hello').html(ejs.rr('templates/hello.ejs', {name: 'Simon'}));
|
$('.hello').html(ejs.rr('templates/hello.ejs', {name: 'Simon'}));
|
||||||
|
|
||||||
|
//a more elaborate example: preload the template to be sure the dom is
|
||||||
|
//ready when manipulated
|
||||||
|
ejs.preloadTemplate('templates/somestuff.ejs')
|
||||||
|
.then(function(t) {
|
||||||
|
$('.sometext').html(ejs.rr(t)); //this is sync now
|
||||||
|
$('.stuff').html('hi!');
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
1
examples/templates/somestuff.ejs
Normal file
1
examples/templates/somestuff.ejs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p class="stuff"></p>
|
Reference in New Issue
Block a user