Skip to content

Commit

Permalink
Commit 69 (v1.0.0-rc.69 - Release Candidate)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisMoore committed Sep 6, 2015
1 parent 2844c61 commit 1b20265
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ or
{{/if}}
```
<h3><i>Node.js features</i></h3>
<h3><i>Node.js Integration</i></h3>
On Node.js *JsRender* provides built-in ***Express***, ***Hapi*** and ***Browserify*** integration. This makes it easy to register templates as simple `.html` files on the file system, and then load and render them either server-side, client-side or both.
Expand Down
13 changes: 7 additions & 6 deletions jsrender-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsRender v1.0.0-rc.68 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! JsRender v1.0.0-rc.69 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! **VERSION FOR NODE.JS** (For WEB see http://jsviews.com/download/jsrender.js) */
/*
* Best-of-breed templating in browser or on Node.js.
Expand Down Expand Up @@ -94,6 +94,7 @@ var versionNumber = "v1.0.0-beta",
tmplFn: tmplFn,
parse: parseParams,
extend: $extend,
extendCtx: extendCtx,
syntaxErr: syntaxError,
onStore: {},
_ths: tagHandlersFromProps,
Expand Down Expand Up @@ -200,7 +201,7 @@ function $viewsDelimiters(openChars, closeChars, link) {
delimCloseChar0 = closeChars ? closeChars.charAt(0) : delimCloseChar0;
delimCloseChar1 = closeChars ? closeChars.charAt(1) : delimCloseChar1;
linkChar = link || linkChar;
openChars = "\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1; // Default is "{^{"
openChars = "\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1; // Default is "{^{"
closeChars = "\\" + delimCloseChar0 + "\\" + delimCloseChar1; // Default is "}}"
// Build regex with new delimiters
// tag (followed by / space or }) or cvtr+colon or html or code
Expand Down Expand Up @@ -612,7 +613,7 @@ function View(context, type, parentView, data, template, key, contentTmpl, onRen
// If the data is an array, this is an 'array view' with a views array for each child 'item view'
// If the data is not an array, this is an 'item view' with a views 'hash' object for any child nested views
// ._.useKey is non zero if is not an 'array view' (owning a data array). Use this as next key for adding to child views hash
self_ = self._ = {
self_ = self._ = {
key: 0,
useKey: isArray ? 0 : 1,
id: "" + viewId++,
Expand Down Expand Up @@ -696,7 +697,7 @@ function compileTag(name, tagDef, parentTmpl) {
render: tagDef
};
} else if ("" + tagDef === tagDef) {
tagDef = {template: tagDef};
tagDef = {template: tagDef};
}
if (baseTag = tagDef.baseTag) {
tagDef.flow = !!tagDef.flow; // Set flow property, so defaults to false even if baseTag has flow=true
Expand Down Expand Up @@ -1057,7 +1058,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
if (view) {
contentTmpl = contentTmpl || view.content; // The wrapped content - to be added as #content property on views, below
onRender = onRender || view._.onRender;
context = context || view.ctx;
context = extendCtx(context, view.ctx);
}

if (key === true) {
Expand Down Expand Up @@ -1095,7 +1096,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
for (i = 0, l = data.length; i < l; i++) {
// Create a view for each data item.
if (itemVar) {
setItemVar(data[i]); // use modified ctx with user-named ~item
setItemVar(data[i]); // use modified ctx with user-named ~item
}
childView = new View(newCtx, "item", newView, data[i], tmpl, (key || 0) + i, contentTmpl, onRender);

Expand Down
14 changes: 8 additions & 6 deletions jsrender.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsRender v1.0.0-rc.68 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! JsRender v1.0.0-rc.69 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! **VERSION FOR WEB** (For NODE.JS see http://jsviews.com/download/jsrender-node.js) */
/*
* Best-of-breed templating in browser or on Node.js.
Expand Down Expand Up @@ -118,6 +118,7 @@ var versionNumber = "v1.0.0-beta",
tmplFn: tmplFn,
parse: parseParams,
extend: $extend,
extendCtx: extendCtx,
syntaxErr: syntaxError,
onStore: {},
_ths: tagHandlersFromProps,
Expand Down Expand Up @@ -224,7 +225,7 @@ function $viewsDelimiters(openChars, closeChars, link) {
delimCloseChar0 = closeChars ? closeChars.charAt(0) : delimCloseChar0;
delimCloseChar1 = closeChars ? closeChars.charAt(1) : delimCloseChar1;
linkChar = link || linkChar;
openChars = "\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1; // Default is "{^{"
openChars = "\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1; // Default is "{^{"
closeChars = "\\" + delimCloseChar0 + "\\" + delimCloseChar1; // Default is "}}"
// Build regex with new delimiters
// tag (followed by / space or }) or cvtr+colon or html or code
Expand Down Expand Up @@ -636,7 +637,7 @@ function View(context, type, parentView, data, template, key, contentTmpl, onRen
// If the data is an array, this is an 'array view' with a views array for each child 'item view'
// If the data is not an array, this is an 'item view' with a views 'hash' object for any child nested views
// ._.useKey is non zero if is not an 'array view' (owning a data array). Use this as next key for adding to child views hash
self_ = self._ = {
self_ = self._ = {
key: 0,
useKey: isArray ? 0 : 1,
id: "" + viewId++,
Expand Down Expand Up @@ -720,7 +721,7 @@ function compileTag(name, tagDef, parentTmpl) {
render: tagDef
};
} else if ("" + tagDef === tagDef) {
tagDef = {template: tagDef};
tagDef = {template: tagDef};
}
if (baseTag = tagDef.baseTag) {
tagDef.flow = !!tagDef.flow; // Set flow property, so defaults to false even if baseTag has flow=true
Expand Down Expand Up @@ -1113,7 +1114,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
if (view) {
contentTmpl = contentTmpl || view.content; // The wrapped content - to be added as #content property on views, below
onRender = onRender || view._.onRender;
context = context || view.ctx;
context = extendCtx(context, view.ctx);
}

if (key === true) {
Expand Down Expand Up @@ -1151,7 +1152,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
for (i = 0, l = data.length; i < l; i++) {
// Create a view for each data item.
if (itemVar) {
setItemVar(data[i]); // use modified ctx with user-named ~item
setItemVar(data[i]); // use modified ctx with user-named ~item
}
childView = new View(newCtx, "item", newView, data[i], tmpl, (key || 0) + i, contentTmpl, onRender);

Expand Down Expand Up @@ -1865,6 +1866,7 @@ if (!(jsr || $ && $.render)) {
$extend(jq, $); // map over from jsrender namespace to jQuery namespace
$ = jq;
$.fn.render = $fnRender;
delete $.jsrender;
}
};

Expand Down
4 changes: 2 additions & 2 deletions jsrender.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsrender.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsrender",
"version": "v1.0.0-rc.68",
"version": "v1.0.0-rc.69",
"description": "Best-of-breed templating in browser or on Node.js (with Express 4, Hapi and Browserify integration)",
"main": "./jsrender-node.js",
"browser": "./jsrender.js",
Expand Down
2 changes: 1 addition & 1 deletion test/browserify/bundles/browserify-bundles-go-here.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Run
$ gulp bundle
to generated browserify client bundles used in the unit tests: test/unit-tests-browserify.html
to generate browserify client bundles used in the unit tests: test/unit-tests-browserify.html
7 changes: 4 additions & 3 deletions test/unit-tests/tests-jsrender-amd-scriptloader.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/*global test, equal, module, ok*/
(function(global, jQuery, undefined) {
"use strict";
if (!window.attachEvent || window.addEventListener) { // Running RequireJS in qunit async test seems to fail in IE8

module("AMD Script Loader");

function undefine() { // Undefine registered modules from previously run tests.
require.undef("jsrender");
require.undef("jquery");
delete window.jQuery;
}

if (!window.attachEvent || window.addEventListener) { // Running RequireJS in qunit async test seems to fail in IE8

module("AMD Script Loader");

test("Loading JsRender, without jQuery, using RequireJS", function(assert) {
var done = assert.async(),
jq = window.jQuery;
Expand Down
31 changes: 18 additions & 13 deletions test/unit-tests/tests-jsrender-no-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,11 @@ test("", function() {
}

// ................................ Assert ..................................
ok(tmpl.useViews === false && message.indexOf("data") > 0,
ok(tmpl.useViews === false && message.indexOf("undefined") > 0,
"A simple template with useViews=false will not provide access to the views through allowCode");

// ................................ Act ..................................
message = "";
tmpl.useViews = true;

// ................................ Assert ..................................
Expand All @@ -687,22 +688,26 @@ test("", function() {
});

// ................................ Assert ..................................
equal(tmpl.useViews && tmpl.render({towns: towns}), "Seattle, Paris and Delhi",
"Recompiling the template with useViews: true will create a template that has tmpl.useViews = true, which renders with views");
tmpl = $.templates(
"{{:#type}} "
+ "{{for towns}}"
+ "{{>name}}"
+ "{{*:view.index===view.parent.data.length-2 ? ' and ' : view.index<view.parent.data.length-2 ? ', ': ''}}"
+ "{{/for}}");

var html = tmpl.render({towns: towns});

equal(tmpl.useViews && html, "data Seattle, Paris and Delhi",
"Recompiling the template with useViews: true will create a template that has tmpl.useViews = true, which renders with a 'data' view");

// ................................ Act ..................................
tmpl.useViews = false;

try {
tmpl.render({towns: towns});
}
catch (e) {
message = e.message;
}
html = tmpl.render({towns: towns});

// ................................ Assert ..................................
ok(message.indexOf("data") > 0,
"If tmpl.useViews set to false (for an existing template - without recompiling), the template renders without views");
equal(!tmpl.useViews && html, "top Seattle, Paris and Delhi",
"If tmpl.useViews set to false (for an existing template - without recompiling), the template renders without a 'data' view");

// ................................ Act ..................................
$.views.settings.useViews = true;
Expand All @@ -712,8 +717,8 @@ test("", function() {
$.views.settings.useViews = false;

// ................................ Assert ..................................
equal(tmpl.useViews && tmpl.render({towns: towns}), "Seattle, Paris and Delhi",
"If $.views.settings.useViews was true when the template is compiled, then the template renders with views, even if $.views.settings.useViews is not longer set to true");
equal(tmpl.useViews && tmpl.render({towns: towns}), "data Seattle, Paris and Delhi",
"If $.views.settings.useViews was true when the template was compiled, then the template renders with views, even if $.views.settings.useViews is no longer set to true");

// =============================== Arrange ===============================
$.views.settings.useViews = false;
Expand Down
2 changes: 1 addition & 1 deletion tmplify/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsRender tmplify submodule v1.0.0-rc.68 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! JsRender tmplify submodule v1.0.0-rc.69 (Beta - Release Candidate): http://jsviews.com/#jsrender */
/*! Browserify transform for JsRender templates */
/*
* Copyright 2015, Boris Moore
Expand Down

0 comments on commit 1b20265

Please sign in to comment.