first commit

This commit is contained in:
s2
2024-12-13 08:53:01 +01:00
commit 2746dc9c4e
5477 changed files with 682458 additions and 0 deletions

14
node_modules/ejs-render-remote/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,14 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
[*.md]
max_line_length = off
trim_trailing_whitespace = false

1
node_modules/ejs-render-remote/.eslintignore generated vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

34
node_modules/ejs-render-remote/.eslintrc.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{"parserOptions":
{"ecmaVersion": 6},
"rules": {
"quotes": [2, "single", {"allowTemplateLiterals": true}],
"curly": [2, "all"],
"keyword-spacing": [2, {"overrides": {"else": {"before": true}, "catch": {"before": true, "after": false}}}],
"space-before-blocks": [2, "always"],
"wrap-iife": [2, "inside"],
"space-before-function-paren": [2, "never"],
"one-var": [2, "never"],
"vars-on-top": 0, "no-empty": [2, {"allowEmptyCatch": true}],
"array-bracket-spacing": [2, "never"],
"space-in-parens": [2, "never"],
"no-underscore-dangle": 0,
"comma-style": [2, "last"],
"comma-spacing": [2, {"before": false, "after": true}],
"space-unary-ops": [2, {"words": false, "nonwords": false}],
"no-multi-spaces": 2,
"space-infix-ops": 2,
"no-with": 2,
"indent": [2, "tab", {"SwitchCase": 1, "FunctionExpression": {"body": 1, "parameters": 1}, "MemberExpression": 0}],
"no-mixed-spaces-and-tabs": 2,
"no-trailing-spaces": 2,
"comma-dangle": [2, "never"],
"semi": [2, "always"],
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
"eol-last": 2,
"dot-notation": 0,
"no-multi-str": 2,
"key-spacing": [2, {"afterColon": true}],
"func-call-spacing": [2, "never"],
"no-console": "warn"
}
}

36
node_modules/ejs-render-remote/README.md generated vendored Normal file
View File

@@ -0,0 +1,36 @@
# ejs-render-remote
[ejs](https://ejs.co/) remote client side includes.
```js
html = ejs.rr('sayhello.ejs', {name: 'Simon'});
```
## Quick start
0. Install with `npm i ejs-render-remote`
1. Include this script
```html
<script src="node_modules/ejs-render-remote/ejs-render-remote.js"></script>
```
2. Create a file with your template, for example `templates/hello-world.ejs` containing `hello <%= name %>!`
3. Render the remote template:
```js
someDomelement.outerHTML = ejs.rr('templates/hello-world.ejs', {name: 'Simon'});
```
## Examples
See `examples` folder.
## api
### ejs.rr(templateUrl, data)
`ejs.rr` (render remote) renders the remote template. It makes an ajax call to fetch the template and then `ejs.render`s it.
The resulting ejs template function is cached, so the second time this function is invoked for that same template, `ejs.rr` returns the rendered template synchronously.
### ejs.preloadTemplate(templateUrl)
Since `ejs.rr` is async, you can call `ejs.preloadTemplate` before invoking `ejs.rr` to warm the template cache up for that `templateUrl`.
By doing so the call to `ejs.rr` will return the rendered template string right away.

86
node_modules/ejs-render-remote/ejs-render-remote.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
//this uses jQuery for now because ie11 support is needed (promises, fetch, Object.assign)
(function($) {
var uuidv4 = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0;
var v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};
var overwriteWithCacheOptions = function(options, cacheName) {
var cacheOptions = {
cache: true,
filename: cacheName
};
var templateOptions = options || {};
return $.extend(templateOptions, cacheOptions);
};
ejs.rr = function(templateUrl, data, options) {
var templateFn = ejs.cache.get(templateUrl);
//if the template is already cached, return it and we are done
if (templateFn) {
return templateFn(data);
} else { //if the template is not cached, we need to get it and render it later once we have it. remember: this happens only if the template is not already cached
//is there a getFn for this template?
var getTemplateFn = ejs.cache.get('getFnFor' + templateUrl);
if (!getTemplateFn) {
getTemplateFn = $.get(templateUrl);
ejs.cache.set('getFnFor' + templateUrl, getTemplateFn);
}
var r = uuidv4();
getTemplateFn.done(function(template) {
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
try {
$('#' + r).replaceWith(ejs.render(
template,
data,
templateOptions
));
} catch(ex) {
$.readyException(ex);
}
//clean up the getFnFor
if (ejs.cache.remove && ejs.cache.get('getFnFor' + templateUrl)) {
ejs.cache.remove('getFnFor' + templateUrl);
}
});
return '<span class="ejs-templateplaceholder" style="display: none;" id="' + r + '"></span>';
}
};
ejs.preloadTemplate = function(templateUrl, options) {
var d = $.Deferred();
//if the template is already cached, just return.
if (ejs.cache.get(templateUrl)) {
d.resolve(templateUrl);
} else {
$.get(templateUrl)
.done(function(template) {
try {
var templateOptions = overwriteWithCacheOptions(options, templateUrl);
var templateFn = ejs.compile(template, templateOptions);
ejs.cache.set(templateUrl, templateFn);
d.resolve(templateUrl);
} catch(ex) {
$.readyException(ex);
d.reject(ex);
}
});
}
return d;
};
})(jQuery);

1
node_modules/ejs-render-remote/examples/ejs.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

32
node_modules/ejs-render-remote/examples/index.html generated vendored Normal file
View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ejs-render-remote example</title>
</head>
<body>
<h1>ejs-render-remote example</h1>
<p class="hello"></p>
<div class="sometext"></div>
<script src="jquery.min.js"></script>
<script src="ejs.min.js"></script>
<script src="../ejs-render-remote.js"></script>
<script>
//render the template
$('.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>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
Hello <%= name %>!

View File

@@ -0,0 +1 @@
<p class="stuff"></p>

48
node_modules/ejs-render-remote/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"_args": [
[
"ejs-render-remote@1.0.13",
"D:\\Projects\\siag\\vanillajs-seed"
]
],
"_from": "ejs-render-remote@1.0.13",
"_id": "ejs-render-remote@1.0.13",
"_inBundle": false,
"_integrity": "sha512-i7wHh2ofonx0+lZTrWxaY0jvXVh+Q240YHV/0zdbWQ3fzeiWJrRTK4ubRb07h5ovbn2O9VGnEmweoG78xN1Xaw==",
"_location": "/ejs-render-remote",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "ejs-render-remote@1.0.13",
"name": "ejs-render-remote",
"escapedName": "ejs-render-remote",
"rawSpec": "1.0.13",
"saveSpec": null,
"fetchSpec": "1.0.13"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/ejs-render-remote/-/ejs-render-remote-1.0.13.tgz",
"_spec": "1.0.13",
"_where": "D:\\Projects\\siag\\vanillajs-seed",
"author": {
"name": "s2",
"email": "s2@31337.it"
},
"description": "[ejs](https://ejs.co/) remote client side includes.",
"homepage": "https://github.com/S2-/ejs-render-remote",
"keywords": [
"ejs",
"templating",
"client-side"
],
"license": "ISC",
"main": "index.js",
"name": "ejs-render-remote",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.13"
}