Skip to content

Commit 7ef0caa

Browse files
committed
Switch from require() to import()
1 parent c0b04ee commit 7ef0caa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+311
-3101
lines changed

.eslintrc.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Dependency directories
21
node_modules
32

43
examples/**/*.map
54
examples/**/*.xml
65
examples/**/*.css
76

8-
package-lock.json
7+
package-lock.json

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016-2021 Stadt Bielefeld - Amt für Geoinformation und Kataster
3+
Copyright (c) 2016-2023 Stadt Bielefeld
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ The module mapfile-ejs allows you to use [Embedded JavaScript (EJS)](http://ejs.
44

55
## Installation
66

7-
1. Install `Node.js` and `npm` from <https://nodejs.org/>
8-
2. Install `mapfile-ejs` with `npm i mapfile-ejs -g`
7+
1. Install `Node.js` and `npm` from [https://nodejs.org/](https://nodejs.org/)
8+
2. Install `mapfile-ejs` with `npm install mapfile-ejs --global`
99

1010
## Getting started
1111

@@ -18,13 +18,13 @@ If you watch a directory, all \*.emap files will be rendering to \*.map files.
1818
Usage: emap [options]
1919
2020
Options:
21-
-h, --help Output usage information
22-
-V, --version Output the version number
23-
-d, --directory [type] Input directory of mapfiles with EJS (*.emap) (default: current directory)
24-
-i, --inputEncoding [type] Encoding of input mapfiles with EJS (default: utf8)
25-
-o, --outputEncoding [type] Encoding of output mapfiles without EJS (default: utf8)
26-
-r, --ignoreInitial Ignore rendering of mapfiles with EJS on initial (default: false)
27-
-e, --eFiles Render all e files like *.exml, *.ecss (default: false)
21+
-h, --help Output usage information
22+
-V, --version Output the version number
23+
-d, --directory <string> Input directory of mapfiles with EJS (*.emap) (default: current directory)
24+
-i, --inputEncoding <string> Encoding of input mapfiles with EJS (default: utf8)
25+
-o, --outputEncoding <string> Encoding of output mapfiles without EJS (default: utf8)
26+
-r, --ignoreInitial Ignore rendering of mapfiles with EJS on initial (default: false)
27+
-e, --eFiles Render all e files like *.exml, *.ecss (default: false)
2828
2929
Examples:
3030
Start watching and rendering with default options:
@@ -39,26 +39,28 @@ Usage: emap [options]
3939
**Render a file:**
4040

4141
```js
42-
const render = require(`mapfile-ejs`).render;
43-
44-
// render file with default options
45-
const r1 = render(
46-
`${__dirname}/template__utf8.emap`,
47-
`${__dirname}/template__utf8.map`
48-
);
49-
50-
// render file with custom options
51-
render(
52-
`${__dirname}/template__iso_8859_1.emap`,
53-
`${__dirname}/template__iso_8859_1__02.map`,
54-
{ inputEncoding: `ISO-8859-1`, outputEncoding: `ISO-8859-1` }
55-
);
42+
import { render } from 'mapfile-ejs';
43+
44+
(async () => {
45+
// render file with default options
46+
const r1 = render(
47+
`${__dirname}/template__utf8.emap`,
48+
`${__dirname}/template__utf8.map`
49+
);
50+
51+
// render file with custom options
52+
render(
53+
`${__dirname}/template__iso_8859_1.emap`,
54+
`${__dirname}/template__iso_8859_1__02.map`,
55+
{ inputEncoding: `ISO-8859-1`, outputEncoding: `ISO-8859-1` }
56+
);
57+
})();
5658
```
5759

5860
**Watch a directory:**
5961

6062
```js
61-
const watch = require(`mapfile-ejs`).watch;
63+
import { watch } from 'mapfile-ejs';
6264

6365
// watch a directory with default options
6466
watch(`dir1`);
@@ -114,33 +116,22 @@ END
114116

115117
```js
116118
<%
117-
// require is available like
118-
const path = require(`path`);
119+
// import is available like
120+
const path = await import(`node:path`);
119121
-%>
120122

121123
<%
122124
// include is available (include_file.ejs) like
123125
-%>
124-
<%- include('include_file', { }); %>
126+
<%- await include('include_file', { }); %>
125127
```
126128

127-
## Documentation
128-
129-
- [API Documentation](https://stadt-bielefeld.github.io/mapfile-ejs/docs/api/index.html)
130-
- [Changelog](https://github.com/stadt-bielefeld/mapfile-ejs/tree/master/docs/changelog/index.md)
131-
132129
## Developer
133130

134-
**Build API Documentation:**
135-
136-
```bash
137-
npm run build-api-doc
138-
```
139-
140131
**Run cli during development:**
141132

142133
```bash
143-
npm run emap -- -d ./examples/watchDir/dir1
134+
npm run emap -- -d ./examples/watch/dir1
144135
```
145136

146137
**Run examples:**
@@ -151,6 +142,57 @@ node examples/render/index.js
151142
node examples/watch/index.js
152143
```
153144

145+
## Changelog
146+
147+
### v3.0.0
148+
149+
* Update dependencies (2023-04-27)
150+
* Switch from `require()`to `import()` (2023-04-27)
151+
* Remove api documentation (2023-04-27)
152+
* Remove ESLint configuration file `.eslintrc.js` (2023-04-27)
153+
154+
### v2.0.7
155+
156+
* Update dependencies
157+
158+
### v2.0.6
159+
160+
* Fix npm bug
161+
162+
### v2.0.5
163+
164+
* Change npm publisher
165+
166+
### v2.0.4
167+
168+
* Update dependencies
169+
170+
### v2.0.3
171+
172+
* Update dependencies
173+
174+
### v2.0.2
175+
176+
* Update mistaks in `README.md`
177+
178+
### v2.0.1
179+
180+
* Fix log bugs in the cli tool `emap`
181+
* Addexamples in `README.md`
182+
183+
### v2.0.0
184+
185+
* Add API Documentation `docs/api`
186+
* Add changelog `docs/changelog`
187+
* Add ESLint configuration file `.eslintrc.js`
188+
* Add Visual Studio Code configuration `.vscode/settings.json`
189+
* Restructure code in `src` directory
190+
* Add npm script `npm run cli -d ./examples/watchDir/dir1`
191+
* Update dependencies
192+
* Switch from class `MapfileRenderer` to module with `render()` and `watch()` function
193+
* Add `isTemplate()` function
194+
* Add new examples
195+
154196
## License
155197

156198
[MIT](https://github.com/stadt-bielefeld/mapfile-ejs/blob/master/LICENSE)

0 commit comments

Comments
 (0)