Skip to content

Commit 207033d

Browse files
committed
fix readme
1 parent 6b627f5 commit 207033d

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,37 @@ SYNOPSIS
3939
</div>
4040
</script>
4141
<script type="module">
42-
import { extended as template } from './lib/micro-template.js';
42+
import { extended as template } from 'https://cdn.jsdelivr.net/npm/micro-template@2.1.2/lib/micro-template.js';
4343
console.log('micro-template.js loaded', template);
4444
console.log('Template example:', template('tmpl1', { isFoo: true, foobar: "a", foobaz: "b" }));
45+
var html = template('tmpl1', {
46+
isFoo : true,
47+
foobar : 'foobar!!',
48+
foobaz : 'foobaz!!',
49+
html : '<marquee>Helloooo</marquee>'
50+
});
51+
console.log(html);
4552
</script>
4653
</body>
4754
</html>
4855
```
4956

50-
```js
51-
// foo.js
52-
window.onload = function () {
53-
var html = template('tmpl1', {
54-
isFoo : true,
55-
foobar : 'foobar!!',
56-
foobaz : 'foobaz!!',
57-
html : '<marquee>Helloooo</marquee>'
58-
});
59-
console.log(html);
60-
};
61-
```
62-
6357
### on node.js:
6458

59+
```
60+
npm install micro-template
61+
```
62+
6563
```js
64+
import fs from 'node:fs';
6665
import { template } from 'micro-template';
67-
template.get = function (id) { return require('fs').readFileSync('tmpl/' + id + '.tmpl', 'utf-8') };
66+
template.get = (id) => fs.readFileSync(`tmpl/${id}.tmpl`, 'utf-8');
6867

6968
const result = template('part1', {
7069
foo : 'bar',
7170
baz : 'piyo'
7271
});
72+
conole.log(result)
7373
```
7474

7575
SYNTAX

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ <h2>Benchmark</h2>
230230
</script>
231231
<script type="module">
232232
import { extended as template } from './lib/micro-template.js';
233+
233234
console.log('micro-template.js loaded', template);
234235
console.log('Template example:', template('tmpl1', { message: 'Hello, world!' }));
235236
</script>

0 commit comments

Comments
 (0)