mirror of
https://github.com/S2-/ejs-render-remote
synced 2025-08-02 20:50:04 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
2701eb3060 | |||
ad9d3b9be9 | |||
21d9319f97 | |||
371d16bc2e | |||
d53c239f90 | |||
6635965706 | |||
dfcf1a4b6f | |||
4b3df71c6b | |||
af63b77c9b | |||
9aba0176f4 | |||
75401b90dd |
@@ -28,6 +28,7 @@
|
|||||||
"dot-notation": 0,
|
"dot-notation": 0,
|
||||||
"no-multi-str": 2,
|
"no-multi-str": 2,
|
||||||
"key-spacing": [2, {"afterColon": true}],
|
"key-spacing": [2, {"afterColon": true}],
|
||||||
"func-call-spacing": [2, "never"]
|
"func-call-spacing": [2, "never"],
|
||||||
|
"no-console": "warn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var r = uuidv4();
|
var r = uuidv4();
|
||||||
getTemplateFn.then(function(template) {
|
getTemplateFn.done(function(template) {
|
||||||
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
templateOptions
|
templateOptions
|
||||||
));
|
));
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
console.error(templateUrl, ex);
|
$.readyException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//clean up the getFnFor
|
//clean up the getFnFor
|
||||||
@@ -68,18 +68,16 @@
|
|||||||
d.resolve(templateUrl);
|
d.resolve(templateUrl);
|
||||||
} else {
|
} else {
|
||||||
$.get(templateUrl)
|
$.get(templateUrl)
|
||||||
.then(function(template) {
|
.done(function(template) {
|
||||||
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
|
||||||
try {
|
try {
|
||||||
|
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
||||||
var templateFn = ejs.compile(template, templateOptions);
|
var templateFn = ejs.compile(template, templateOptions);
|
||||||
|
ejs.cache.set(templateUrl, templateFn);
|
||||||
|
d.resolve(templateUrl);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
console.error(templateUrl, ex);
|
$.readyException(ex);
|
||||||
d.reject(ex);
|
d.reject(ex);
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
ejs.cache.set(templateUrl, templateFn);
|
|
||||||
|
|
||||||
d.resolve(templateUrl);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
examples/ejs.min.js
vendored
2
examples/ejs.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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>
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ejs-render-remote",
|
"name": "ejs-render-remote",
|
||||||
"version": "1.0.9",
|
"version": "1.0.13",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"homepage": "https://github.com/S2-/ejs-render-remote",
|
"homepage": "https://github.com/S2-/ejs-render-remote",
|
||||||
|
Reference in New Issue
Block a user