Comparing version 0.0.72 to 0.0.73
module.exports = { | ||
isDebug(env){ | ||
return env === 'development'; | ||
isDebugMode(env){ | ||
return env !== "production"; | ||
} | ||
} |
@@ -253,3 +253,3 @@ const htmlEncode = require('js-htmlencode'); | ||
<div class="code"> | ||
<div class="filepath">${fileName}</div></div> | ||
<div class="filepath">${fileName}</div> | ||
${html} | ||
@@ -256,0 +256,0 @@ </div> |
@@ -259,13 +259,6 @@ 'use strict'; | ||
i = jsValues.enq(block.text); | ||
return ` | ||
Html.__dbg.pos = { start:${block.posStart}, end: ${block.posEnd} }; | ||
Html.encode(eval(Html.__val(${i}))); | ||
Html.__dbg.pos = null;`; | ||
let code = `Html.encode(eval(Html.__val(${i})));`; | ||
return debugMode ? setDbg(code, block) : "\r\n" + code; | ||
case blockType.code: | ||
if (debugMode) | ||
return ` | ||
Html.__dbg.pos = { start:${block.posStart}, end: ${block.posEnd} }; | ||
${block.text} | ||
Html.__dbg.pos = null;`; | ||
return "\r\n" + block.text; // to be on a separate line | ||
return debugMode ? setDbg(block.text, block) : "\r\n" + block.text; | ||
default: | ||
@@ -279,2 +272,9 @@ throw new Error(`Unexpected block type = "${blockType}".`); | ||
function setDbg(code, block){ | ||
return ` | ||
Html.__dbg.pos = { start:${block.posStart}, end: ${block.posEnd} }; | ||
${code} | ||
Html.__dbg.pos = null;`; | ||
} | ||
class Queue { | ||
@@ -1445,3 +1445,3 @@ constructor() { | ||
function isDebugMode(opts) { | ||
return opts.debug || dbg.isDebug(opts.mode); | ||
return opts.debug || dbg.isDebugMode(opts.mode); | ||
} | ||
@@ -1448,0 +1448,0 @@ |
@@ -242,3 +242,3 @@ require('./utils'); | ||
if (dbg.isDebug(this.env)) | ||
if (dbg.isDebugMode(this.env)) | ||
return this.wrapInHtmlComment(filename) + EOL + data + endNL; | ||
@@ -245,0 +245,0 @@ |
@@ -48,4 +48,4 @@ 'use strict'; | ||
function handleErrors(app, errorCode, mode) { | ||
mode = mode || "development"; | ||
function handleErrors(app, errorCode) { | ||
const dbg = require('./core/dbg/debugger'); | ||
app.use(appErrorHandler); | ||
@@ -59,3 +59,3 @@ | ||
if (env === mode && err.name === RazorError.name) { | ||
if (dbg.isDebugMode(env) && err.name === RazorError.name) { | ||
var errorHtml = err.html(); | ||
@@ -62,0 +62,0 @@ res.status(errorCode || 500); |
{ | ||
"name": "raz", | ||
"description": "Razor-like 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": "0.0.72", | ||
"version": "0.0.73", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Sergey Fisun", |
@@ -465,2 +465,17 @@ (function () { | ||
{ | ||
name: "Code 54.1", | ||
template: ` | ||
@{ | ||
var a = 1, b = 2; | ||
} | ||
@if (a > b) { | ||
<span>A</span> | ||
} | ||
else if (a === 1) { | ||
<span>B</span> | ||
} | ||
`, | ||
expected: "\n <span>B</span>\n" | ||
}, | ||
{ | ||
name: "Code 55", | ||
@@ -467,0 +482,0 @@ template: ` |
@@ -180,6 +180,8 @@ console.log("STARTED: server.test.js"); | ||
expect(errorViews, '2 error views are expected').to.have.lengthOf(2); | ||
let viewSourceHeader = errorViews.find(`:contains(laytouterror.raz)`); | ||
expect(viewSourceHeader, '"laytouterror.raz" header is expected').to.have.lengthOf(1); | ||
let layoutSourceHeader = errorViews.find(`:contains(_layout.raz)`); | ||
expect(layoutSourceHeader, '"_layout.raz" header is expected').to.have.lengthOf(1); | ||
let viewHeader = $(errorViews[0]).find(`.filepath:contains(laytouterror.raz)`); | ||
expect(viewHeader, '"laytouterror.raz" header is expected').to.have.lengthOf(1); | ||
let layoutHeader = $(errorViews[1]).find(`.filepath:contains(_layout.raz)`); | ||
expect(layoutHeader, '"_layout.raz" header is expected').to.have.lengthOf(1); | ||
let errorText = $(errorViews[1]).find('.multilight').text(); | ||
expect(errorText).equal("@temp"); | ||
console.log(`> testing rote ${route} is done`); | ||
@@ -211,8 +213,10 @@ done(); | ||
expect(errorViews, '3 error views are expected').to.have.lengthOf(3); | ||
let viewSourceHeader = errorViews.find(`:contains(partialerror.raz)`); | ||
let viewSourceHeader = $(errorViews[0]).find(`.filepath:contains(partialerror.raz)`); | ||
expect(viewSourceHeader, '"partialerror.raz" header is expected').to.have.lengthOf(1); | ||
let layoutSourceHeader = errorViews.find(`:contains(_layout.raz)`); | ||
let layoutSourceHeader = $(errorViews[1]).find(`.filepath:contains(_layout.raz)`); | ||
expect(layoutSourceHeader, '"_layout.raz" header is expected').to.have.lengthOf(1); | ||
let partialSourceHeader = errorViews.find(`:contains(_partial.raz)`); | ||
let partialSourceHeader = $(errorViews[2]).find(`.filepath:contains(_partial.raz)`); | ||
expect(partialSourceHeader, '"_partial.raz" header is expected').to.have.lengthOf(1); | ||
let errorText = $(errorViews[2]).find('.multilight').text(); | ||
expect(errorText).equal("@temp"); | ||
console.log(`> testing rote ${route} is done`); | ||
@@ -219,0 +223,0 @@ done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
436389
4392