Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ejse = require('ejs-electron')
Get/set the data (context) that will be passed to `ejs.render()`.

Overloads:
- `ejse.data()` -- Retrieve the current data set.
- `ejse.data('key')` -- Retrieve the value of `'key'` in the current data set.
- `ejse.data('key', 'val')` -- Set `'key'` to `'val' `in the current data set.
- `ejse.data({key: 'val'})` -- Replace the current data set with a new one containing `{key: 'val'}`
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ function protocolListener(request, callback) {


function updateState(field, context, key, val) {
if (typeof key === 'undefined' && typeof val === 'undefined') {
let data = state[field];
delete data.ejse;
return data
}

if (typeof key === 'string') {
if (typeof val === 'undefined') return state[field][key]
state[field][key] = val
Expand Down