Comparing version 1.4.0 to 1.5.0
@@ -64,7 +64,6 @@ 'use strict'; | ||
const log = opts.log || { debug: () => { } }; | ||
log.debug(`Parse debug mode is '${!!debugMode}'.`); | ||
log.debug(`Parser debug mode is '${!!debugMode}'.`); | ||
const HtmlString = require('./HtmlString'); | ||
const htmlEncode = require('./libs/js-htmlencode'); | ||
const vm = opts.vm; | ||
@@ -75,8 +74,8 @@ //////////////////// | ||
function Html(args) { | ||
// Non-user section. | ||
this._vm = vm; | ||
this._vm = null; | ||
if (debugMode && !isBrowser) { | ||
this._vm = require('vm'); | ||
this._sandbox = Object.create(null); | ||
vm.createContext(this._sandbox); | ||
this._vm.createContext(this._sandbox); | ||
} | ||
@@ -87,3 +86,3 @@ | ||
'use strict'; | ||
(function (process, window, global, module, require, compilePage, compilePageSync, navigator, undefined) { | ||
(function (process, window, global, module, require, compilePage, compilePageSync, navigator, undefined) { | ||
delete Html._js; | ||
@@ -211,3 +210,3 @@ delete Html._vm; | ||
if (required) | ||
throw args.er.sectionIsNotFound(name, args.filePath); // [#3.3] | ||
throw args.er.sectionIsNotFound(name, args.filePath); // [#3.3] | ||
} | ||
@@ -697,3 +696,3 @@ | ||
} | ||
else if (openTagName || tag) { // it must be an expression somewhere inside HTML | ||
else if (openTagName || tag) { // it must be an expression somewhere inside HTML | ||
this.fetchChar(); // skip current '@' | ||
@@ -1266,5 +1265,5 @@ this.parseCode(blocks); | ||
if (spaceCount < 1) | ||
throw this.er.whiteSpaceExpectedAfter("@" + _sectionKeyword, this.lineNum, this.linePos()); // unreachable due to previous function check | ||
throw this.er.whiteSpaceExpectedAfter("@" + _sectionKeyword, this.lineNum, this.linePos()); // unreachable due to previous function check | ||
//let sectionLine = this.lineNum; | ||
//let sectionLine = this.lineNum; | ||
let sectionNamePos = this.linePos(); | ||
@@ -1271,0 +1270,0 @@ let sectionName = ''; |
@@ -35,4 +35,3 @@ require('./utils'); | ||
const log = require('./dbg/logger')({ on: debug && allowLoggingInDebugModel }); | ||
const vm = debug ? require('vm') : null; | ||
this.parser = initParser({ express: true, dbg, log, vm }); | ||
this.parser = initParser({ express: true, dbg, log }); | ||
this.viewsDir = path.resolve(this.options.settings.views); | ||
@@ -133,3 +132,3 @@ } | ||
let cachedData = cache && cache[viewPath]; | ||
if (cachedData) | ||
@@ -157,3 +156,3 @@ return cachedData; | ||
let cachedData = cache && cache[filePath]; | ||
if (cachedData) | ||
@@ -182,6 +181,6 @@ return cachedData; | ||
var result = { data, filePath }; | ||
if (cache) | ||
cache[filePath] = result; | ||
return result; | ||
@@ -210,3 +209,3 @@ } | ||
else if (partialViewName[0] === '.') { // it's relative to the current folder | ||
viewPath = path.join(startDir, viewPath); | ||
viewPath = path.join(startDir, viewPath); | ||
} | ||
@@ -259,3 +258,3 @@ | ||
addFileNameIfDev(data, filename) { | ||
addFileNameIfDev(data, filename) { | ||
data = String.stripBOM(data.toString()); | ||
@@ -262,0 +261,0 @@ let endNL = (data[data.length - 1] === '\n') ? '' : '\n'; |
{ | ||
"name": "raz", | ||
"description": "Razor like HTML template engine for NodeJS Express library based on ASP.NET MVC Razor syntax. Template your views by mixing HTML markup with JavaScript server-side code!", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Sergey F.", |
@@ -126,3 +126,3 @@ # Razor-Express (RAZ): a view template engine for NodeJS/ExpressJS | ||
``` | ||
Maybe I'm wrong and this kind of markup really simplifies the development and perception of the code, but to me, it doesn't seem to be so. Let's just compare it to the equivalent **Razor markup**: | ||
Maybe I'm wrong and this kind of markup really simplifies the development and perception of the code, but to me it doesn't seem to be so. Let's just compare it to the equivalent **Razor markup**: | ||
```HTML+Razor | ||
@@ -129,0 +129,0 @@ <div class='item' id='item@item.id'> |
131632
2485