mirror of
https://github.com/S2-/ejs-render-remote
synced 2025-08-03 21:10:04 +02:00
Compare commits
7 Commits
master
...
936d5c1d94
Author | SHA1 | Date | |
---|---|---|---|
![]() |
936d5c1d94 | ||
![]() |
ef5fc54946 | ||
![]() |
df262d40f4 | ||
![]() |
cd74e87dd3 | ||
![]() |
672b80f5a3 | ||
![]() |
2cde5f1226 | ||
37a2512f4b |
@@ -28,7 +28,6 @@
|
|||||||
"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,18 +37,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var r = uuidv4();
|
var r = uuidv4();
|
||||||
getTemplateFn.done(function(template) {
|
getTemplateFn.then(function(template) {
|
||||||
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
||||||
|
|
||||||
try {
|
$('#' + r).replaceWith(ejs.render(
|
||||||
$('#' + r).replaceWith(ejs.render(
|
template,
|
||||||
template,
|
data,
|
||||||
data,
|
templateOptions
|
||||||
templateOptions
|
));
|
||||||
));
|
|
||||||
} catch(ex) {
|
|
||||||
$.readyException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//clean up the getFnFor
|
//clean up the getFnFor
|
||||||
if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) {
|
if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) {
|
||||||
@@ -65,19 +61,15 @@
|
|||||||
|
|
||||||
//if the template is already cached, just return.
|
//if the template is already cached, just return.
|
||||||
if (ejs.cache.get(templateUrl)) {
|
if (ejs.cache.get(templateUrl)) {
|
||||||
d.resolve(templateUrl);
|
d.resolve();
|
||||||
} else {
|
} else {
|
||||||
$.get(templateUrl)
|
$.get(templateUrl)
|
||||||
.done(function(template) {
|
.then(function(template) {
|
||||||
try {
|
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
||||||
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
|
var templateFn = ejs.compile(template, templateOptions);
|
||||||
var templateFn = ejs.compile(template, templateOptions);
|
ejs.cache.set(templateUrl, templateFn);
|
||||||
ejs.cache.set(templateUrl, templateFn);
|
|
||||||
d.resolve(templateUrl);
|
d.resolve(templateUrl);
|
||||||
} catch(ex) {
|
|
||||||
$.readyException(ex);
|
|
||||||
d.reject(ex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
examples/ejs.min.js
vendored
2
examples/ejs.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -9,7 +9,6 @@
|
|||||||
<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>
|
||||||
@@ -19,14 +18,6 @@
|
|||||||
<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 +1 @@
|
|||||||
Hello <%= name %>!
|
Hello <%= name%>!
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
<p class="stuff"></p>
|
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ejs-render-remote",
|
"name": "ejs-render-remote",
|
||||||
"version": "1.0.13",
|
"version": "1.0.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"homepage": "https://github.com/S2-/ejs-render-remote",
|
"homepage": "https://github.com/S2-/ejs-render-remote",
|
||||||
@@ -9,9 +9,5 @@
|
|||||||
},
|
},
|
||||||
"author": "s2 <s2@31337.it>",
|
"author": "s2 <s2@31337.it>",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": ["ejs", "templating", "client-side"]
|
||||||
"ejs",
|
|
||||||
"templating",
|
|
||||||
"client-side"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user