Comparing version 1.3.5 to 1.3.6
@@ -145,3 +145,3 @@ 'use strict'; | ||
this.raw = function (val) { // render | ||
if (typeof val === 'undefined' || val === '') // 'undefined' can be passed when `Html.raw()` is used by user in the view, in this case it will be wrapped into `Html.ecnode()` anyway an it will call `Html.raw` passing 'undefined' to it. | ||
if (!isVisibleValue(val)) // 'undefined' can be passed when `Html.raw()` is used by user in the view, in this case it will be wrapped into `Html.ecnode()` anyway an it will call `Html.raw` passing 'undefined' to it. | ||
return; | ||
@@ -165,3 +165,6 @@ | ||
this.getEncoded = function (val) { | ||
if (!val || typeof val === "number" || val instanceof Number || val instanceof HtmlString) | ||
if (!isVisibleValue(val)) | ||
return ''; | ||
if (typeof val === "number" || val instanceof Number || val instanceof HtmlString) | ||
return val; | ||
@@ -216,3 +219,3 @@ | ||
scope: args.scope, | ||
model: viewModel || args.model, // if is not set explicitly, set default (parent) model | ||
model: viewModel === undefined ? args.model : viewModel, // if is not set explicitly, set default (parent) model | ||
findPartial: args.findPartial, | ||
@@ -267,2 +270,6 @@ findPartialSync: args.findPartialSync, | ||
function isVisibleValue(val) { | ||
return (val != null && val !== ''); | ||
} | ||
function toScript(block, jsValues) { | ||
@@ -269,0 +276,0 @@ if (block.type === blockType.section) { |
@@ -254,4 +254,4 @@ require('./utils'); | ||
addFileNameIfDev(data, filename) { | ||
data = data.toString(); | ||
addFileNameIfDev(data, filename) { | ||
data = String.stripBOM(data.toString()); | ||
let endNL = (data[data.length - 1] === '\n') ? '' : '\n'; | ||
@@ -258,0 +258,0 @@ |
@@ -71,3 +71,3 @@ //////////////////////////////////////////////// | ||
String.prototype.numberOfOccurrences = function(str, max = 2) { | ||
String.prototype.numberOfOccurrences = function (str, max = 2) { | ||
let pos = 0, num = 0, idx = 0; | ||
@@ -79,3 +79,3 @@ | ||
if (idx !== -1){ | ||
if (idx !== -1) { | ||
num++; | ||
@@ -89,2 +89,9 @@ pos = idx; | ||
String.stripBOM = function (str) { | ||
if (str.charCodeAt(0) === 0xFEFF) | ||
return str.slice(1); | ||
return str; | ||
} | ||
//////////////////////////////////////////////// | ||
@@ -91,0 +98,0 @@ // Char |
{ | ||
"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.3.5", | ||
"version": "1.3.6", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Sergey F.", |
131742
2487