Skip to content

Commit 8226c95

Browse files
committed
1.1.2
- Added `teddy.clearTemplates()` method to clear the template cache. - Updated dependencies.
1 parent bc3e092 commit 8226c95

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
- Put your changes here...
66

7+
## 1.1.2
8+
9+
- Added `teddy.clearTemplates()` method to clear the template cache.
10+
- Updated dependencies.
11+
712
## 1.1.1
813

914
- Added support for `variables-with-dashes-in-their-names`.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ API
501501

502502
- `teddy.setTemplate(name, template)`: Add a new template to the template cache.
503503

504+
- `teddy.clearTemplates()`: Clear the template cache.
505+
504506
- `teddy.render(template, model)`: Render a template by supplying either source code or a file name (in Node.js).
505507

506508
- Returns fully rendered HTML.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"nyc": "17.1.0",
4949
"standard": "17.1.2",
5050
"terser-webpack-plugin": "5.3.14",
51-
"webpack": "5.99.3",
51+
"webpack": "5.99.5",
5252
"webpack-cli": "6.0.1"
5353
},
5454
"standard": {

teddy.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cheerioOptions = { xml: { xmlMode: false, lowerCaseAttributeNames: false,
88
const browser = cheerioLoad.isCheerioPolyfill // true if we are executing in the browser context
99
const params = {} // teddy parameters
1010
setDefaultParams() // set params to the defaults
11-
const templates = {} // loaded templates are stored as object collections, e.g. { "myTemplate.html": "<p>some markup</p>"}
11+
let templates = {} // loaded templates are stored as object collections, e.g. { "myTemplate.html": "<p>some markup</p>"}
1212
const caches = {} // a place to store cached portions of templates
1313
const templateCaches = {} // a place to store cached full templates
1414

@@ -1100,6 +1100,11 @@ function setTemplate (file, template) {
11001100
templates[file] = template
11011101
}
11021102

1103+
// mutator method to clear template cache entirely
1104+
function clearTemplates () {
1105+
templates = {}
1106+
}
1107+
11031108
function setCache (params) {
11041109
if (!templateCaches[params.template]) templateCaches[params.template] = {}
11051110
if (params.key) {
@@ -1347,6 +1352,7 @@ export default {
13471352
setIncludeNotFoundBehavior,
13481353
getTemplates,
13491354
setTemplate,
1355+
clearTemplates,
13501356
setCache,
13511357
clearCache,
13521358
render,

0 commit comments

Comments
 (0)