3.0.1 • Published 2 years ago
mapfile-ejs v3.0.1
mapfile-ejs
The module mapfile-ejs allows you to use Embedded JavaScript (EJS) into MapServer Mapfiles.
Installation
- Install
Node.jsandnpmfrom https://nodejs.org/ - Install
mapfile-ejswithnpm install mapfile-ejs -g
Getting started
Use the file extension *.emap for MapServer Mapfiles with EJS. If you watch a directory, all *.emap files will be rendering to *.map files.
Terminal
Usage: emap [options]
Options:
-h, --help Output usage information
-V, --version Output the version number
-d, --directory <string> Input directory of mapfiles with EJS (*.emap) (default: current directory)
-i, --inputEncoding <string> Encoding of input mapfiles with EJS (default: utf8)
-o, --outputEncoding <string> Encoding of output mapfiles without EJS (default: utf8)
-r, --ignoreInitial Ignore rendering of mapfiles with EJS on initial (default: false)
-e, --eFiles Render all e files like *.exml, *.ecss (default: false)
Examples:
Start watching and rendering with default options:
$ emap
Start watching and rendering with custom options:
$ emap -d ./examples -i iso-8859-1 -o iso-8859-1 -r -eJavaScript
Render a file:
import { render } from 'mapfile-ejs';
(async () => {
// render file with default options
await render(
`./template__utf8.emap`,
`./template__utf8.map`
);
// render file with custom options
await render(
`./template__iso_8859_1.emap`,
`./template__iso_8859_1__02.map`,
{ inputEncoding: `ISO-8859-1`, outputEncoding: `ISO-8859-1` }
);
})();Watch a directory:
import { watch } from 'mapfile-ejs';
// watch a directory with default options
watch(`dir1`);
// watch a directory with custom options
watch(`dir2`, {
inputEncoding: `utf8`,
outputEncoding: `utf8`,
eFiles: false,
ignoreInitial: false
});More details are available at the API Documentation and at the examples directory
Mapfile
Input (example.emap):
MAP
<%
//Loop to create 3 layers
for(let i = 0; i < 3; i++) {
-%>
LAYER
NAME "layer_<%- i %>"
END
<%
} //End of loop
-%>
ENDOutput (example.map):
MAP
LAYER
NAME "layer_0"
END
LAYER
NAME "layer_1"
END
LAYER
NAME "layer_2"
END
ENDHow to use require and include:
<%
// import is available like
const path = await import(`node:path`);
-%>
<%
// include is available (include_file.ejs) like
-%>
<%- await include('include_file', { }); %>Developer
Run cli during development:
npm run emap -- -d ./examples/watch/dir1Run examples:
node examples/isTemplate/index.js
node examples/render/index.js
node examples/watch/index.jsChangelog
v3.0.1
- Fix mistakes in README.md (2023-04-28)
v3.0.0
- Update dependencies (2023-04-27)
- Switch from
require()toimport()(2023-04-27) - Switch
render()toasync render()(2023-04-07) - Remove api documentation (2023-04-27)
- Remove ESLint configuration file
.eslintrc.js(2023-04-27)
v2.0.7
- Update dependencies
v2.0.6
- Fix npm bug
v2.0.5
- Change npm publisher
v2.0.4
- Update dependencies
v2.0.3
- Update dependencies
v2.0.2
- Update mistaks in
README.md
v2.0.1
- Fix log bugs in the cli tool
emap - Addexamples in
README.md
v2.0.0
- Add API Documentation
docs/api - Add changelog
docs/changelog - Add ESLint configuration file
.eslintrc.js - Add Visual Studio Code configuration
.vscode/settings.json - Restructure code in
srcdirectory - Add npm script
npm run cli -d ./examples/watchDir/dir1 - Update dependencies
- Switch from class
MapfileRendererto module withrender()andwatch()function - Add
isTemplate()function - Add new examples
License
3.0.1
2 years ago
3.0.0
3 years ago
2.0.7
4 years ago
2.0.6
5 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago