Skip to content

Commit

Permalink
Fix json filter
Browse files Browse the repository at this point in the history
* See: #13
  • Loading branch information
stevenjoezhang committed May 29, 2020
1 parent 2b7a638 commit 4013450
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function njkCompile(data) {
return dictionary;
});
env.addFilter('json', dictionary => {
return JSON.stringify(dictionary || '');
if (typeof dictionary !== 'undefined' && dictionary !== null) {
return JSON.stringify(dictionary);
}
return '""';
});
return nunjucks.compile(data.text, env, data.path);
}
Expand Down

0 comments on commit 4013450

Please sign in to comment.