Skip to content

Commit

Permalink
template: proper eval (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed May 10, 2016
1 parent 1824b69 commit fceff6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"js2xmlparser": "^1.0.0",
"lodash": "^4.x",
"marked": "^0.3.5",
"node-eval": "^1.0.0",
"q": "^2.x",
"rsync-slim": "^1.1.0"
},
Expand Down
11 changes: 8 additions & 3 deletions src/tasks/template/full-bem.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const vm = require('vm');
const path = require('path');

const _ = require('lodash');
const Q = require('q');
const freeze = require('freeze');
const safeEval = require('node-eval');
const baseUtil = require('../../util');

const debug = require('debug')('full-bem');
Expand Down Expand Up @@ -115,9 +115,14 @@ module.exports = function(model, options) {
* @returns {Object} page
*/
function compoundPage(page, content) {
if(_.endsWith(page.contentFile, '.bemjson.js')) {
content = _bemhtml(vm.runInNewContext(content));
if(_.endsWith(page.contentFile, '.js')) {
content = safeEval(content, page.contentFile);

if(_.endsWith(page.contentFile, '.bemjson.js')) {
content = _bemhtml(content);
}
}

return _.set(page, 'content', content);
}

Expand Down

0 comments on commit fceff6a

Please sign in to comment.