Skip to content

Commit

Permalink
Commit 73 (v0.9.73 - Beta)
Browse files Browse the repository at this point in the history
Minor update: no important changes or bug fixes

- Updated copyright and updated links to latest jQuery, QUnit etc.

- Some documentation improvements
  • Loading branch information
BorisMoore committed Feb 16, 2016
1 parent 3708f5a commit 11ebdd8
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 109 deletions.
12 changes: 8 additions & 4 deletions README.md
Expand Up @@ -16,7 +16,7 @@ JsRender is used for data-driven rendering of templates to strings, ready for in

It is also used by the *[JsViews](http://www.jsviews.com/#jsviews)* platform, which adds data binding to JsRender templates, and provides a fully-fledged MVVM platform for easily creating interactive data-driven single page apps and websites.

<h3>Installation</h3>
<h2>JsRender Installation</h2>

*jsrender.js* is available from [downloads](http://www.jsviews.com/#download) on the jsviews.com site.

Expand All @@ -25,12 +25,14 @@ It is also used by the *[JsViews](http://www.jsviews.com/#jsviews)* platform, wh
Alternatively:
- It can be installed with ***[Bower](http://bower.io/search/?q=jsrender)***, using `$ bower install jsrender`
- It can be loaded using an *AMD script loader*, such as RequireJS
- For installation using *Node.js* (*npm*) see *[JsRender Node.js Quickstart](http://www.jsviews.com/#jsr-node-quickstart)*
- For installation using *Node.js* (*npm*) see *[JsRender Node.js Quickstart](#jsr-node-quickstart)*

<h4><b>jQuery integration</b></h4>
<h4><b>Using JsRender with jQuery</b></h4>
When jQuery is present, JsRender loads as a jQuery plugin and adds `$.views`, `$.templates` and `$.render` to the jQuery namespace object, `$` (or `window.jQuery`).

<h4><b>JsRender without jQuery</b></h4>
*Example HTML page:* [JsRender with jQuery](http://www.jsviews.com/#download/pages-jsr-jq)

<h4><b>Using JsRender without jQuery</b></h4>

When jQuery is not present, JsRender provides its own `jsrender` namespace object, exposed as `window.jsrender`

Expand All @@ -42,6 +44,8 @@ var $ = window.jsrender;
// Now use code as in samples/examples, with $.views... $.templates... $.render...
```

*Example HTML page:* [JsRender without jQuery](http://www.jsviews.com/#download/pages-jsr)

<h4><b>JsRender on Node.js</b></h4>

JsRender can be used to render templates on the server (using Node.js) as well as in the browser. JsRender on Node.js has all the features and APIs of JsRender in the browser, plus some additional ones specific to Node.js.
Expand Down
40 changes: 20 additions & 20 deletions jsrender-node.js
@@ -1,11 +1,11 @@
/*! JsRender v0.9.72 (Beta): http://jsviews.com/#jsrender */
/*! JsRender v0.9.73 (Beta): 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.
* Does not require jQuery, or HTML DOM
* Integrates with JsViews (http://jsviews.com/#jsviews)
*
* Copyright 2015, Boris Moore
* Copyright 2016, Boris Moore
* Released under the MIT License.
*/

Expand All @@ -19,7 +19,7 @@ if (typeof exports !== 'object' ) {

//========================== Top-level vars ==========================

var versionNumber = "v0.9.72",
var versionNumber = "v0.9.73",

// global var is the this object, which is window when running in the usual browser environment
global = (0, eval)('this'), // jshint ignore:line
Expand Down Expand Up @@ -211,10 +211,10 @@ function $viewsDelimiters(openChars, closeChars, link) {
// make rTag available to JsViews (or other components) for parsing binding expressions
$sub.rTag = "(?:" + rTag + ")";
// { ^? { tag+params slash? or closingTag or comment
rTag = new RegExp("(?:" + openChars + rTag + "(\\/)?|\\" + delimOpenChar0 + "\\" + delimOpenChar1 + "(?:(?:\\/(\\w+))\\s*|!--[\\s\\S]*?--))" + closeChars, "g");
rTag = new RegExp("(?:" + openChars + rTag + "(\\/)?|\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1 + "(?:(?:\\/(\\w+))\\s*|!--[\\s\\S]*?--))" + closeChars, "g");

// Default: bind tagName cvt cln html code params slash closeBlk comment
// /(?:{(\^)?{(?:(\w+(?=[/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{{(?:(?:\/(\w+))|!--[\s\S]*?--))}}/g
// Default: bind tagName cvt cln html code params slash bind2 closeBlk comment
// /(?:{(\^)?{(?:(\w+(?=[\/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{(\^)?{(?:(?:\/(\w+))\s*|!--[\s\S]*?--))}}

rTmplString = new RegExp("<.*>|([^\\\\]|^)[{}]|" + openChars + ".*" + closeChars);
// rTmplString looks for html tags or { or } char not preceded by \\, or JsRender tags {{xxx}}. Each of these strings are considered
Expand Down Expand Up @@ -1168,43 +1168,43 @@ function tmplFn(markup, tmpl, isLinkExpr, convertBack, hasElse) {
}
}

function parseTag(all, bind, tagName, converter, colon, html, codeTag, params, slash, closeBlock, index) {
function parseTag(all, bind, tagName, converter, colon, html, codeTag, params, slash, bind2, closeBlock, index) {
/*
bind tagName cvt cln html code params slash closeBlk comment
/(?:{(\^)?{(?:(\w+(?=[/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{{(?:(?:\/(\w+))|!--[\s\S]*?--))}}/g
bind tagName cvt cln html code params slash bind2 closeBlk comment
/(?:{(\^)?{(?:(\w+(?=[\/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{(\^)?{(?:(?:\/(\w+))\s*|!--[\s\S]*?--))}}/g
(?:
{(\^)?{ bind
{(\^)?{ bind
(?:
(\w+ tagName
(\w+ tagName
(?=[\/\s}])
)
|
(\w+)?(:) converter colon
(\w+)?(:) converter colon
|
(>) html
(>) html
|
(\*) codeTag
(\*) codeTag
)
\s*
( params
( params
(?:[^}]|}(?!}))*?
)
(\/)? slash
(\/)? slash
|
{{
{(\^)?{ bind2
(?:
(?:\/(\w+)) closeBlock
(?:\/(\w+))\s* closeBlock
|
!--[\s\S]*?-- comment
!--[\s\S]*?-- comment
)
)
}}/g
*/

if (codeTag && bind || slash && !tagName || params && params.slice(-1) === ":") {
if (codeTag && bind || slash && !tagName || params && params.slice(-1) === ":" || bind2) {
syntaxError(all);
}

Expand Down
42 changes: 21 additions & 21 deletions jsrender.js
@@ -1,11 +1,11 @@
/*! JsRender v0.9.72 (Beta): http://jsviews.com/#jsrender */
/*! JsRender v0.9.73 (Beta): 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.
* Does not require jQuery, or HTML DOM
* Integrates with JsViews (http://jsviews.com/#jsviews)
*
* Copyright 2015, Boris Moore
* Copyright 2016, Boris Moore
* Released under the MIT License.
*/

Expand All @@ -32,7 +32,7 @@
}
} (

// factory (for jquery.views.js)
// factory (for jsrender.js)
function($) {
"use strict";

Expand All @@ -44,7 +44,7 @@ var global = (0, eval)('this'), // jshint ignore:line

$ = $ && $.fn ? $ : global.jQuery; // $ is jQuery passed in by CommonJS loader (Browserify), or global jQuery.

var versionNumber = "v0.9.72",
var versionNumber = "v0.9.73",
jsvStoreName, rTag, rTmplString, topView, $views,

//TODO tmplFnsCache = {},
Expand Down Expand Up @@ -235,10 +235,10 @@ function $viewsDelimiters(openChars, closeChars, link) {
// make rTag available to JsViews (or other components) for parsing binding expressions
$sub.rTag = "(?:" + rTag + ")";
// { ^? { tag+params slash? or closingTag or comment
rTag = new RegExp("(?:" + openChars + rTag + "(\\/)?|\\" + delimOpenChar0 + "\\" + delimOpenChar1 + "(?:(?:\\/(\\w+))\\s*|!--[\\s\\S]*?--))" + closeChars, "g");
rTag = new RegExp("(?:" + openChars + rTag + "(\\/)?|\\" + delimOpenChar0 + "(\\" + linkChar + ")?\\" + delimOpenChar1 + "(?:(?:\\/(\\w+))\\s*|!--[\\s\\S]*?--))" + closeChars, "g");

// Default: bind tagName cvt cln html code params slash closeBlk comment
// /(?:{(\^)?{(?:(\w+(?=[/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{{(?:(?:\/(\w+))|!--[\s\S]*?--))}}/g
// Default: bind tagName cvt cln html code params slash bind2 closeBlk comment
// /(?:{(\^)?{(?:(\w+(?=[\/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{(\^)?{(?:(?:\/(\w+))\s*|!--[\s\S]*?--))}}

rTmplString = new RegExp("<.*>|([^\\\\]|^)[{}]|" + openChars + ".*" + closeChars);
// rTmplString looks for html tags or { or } char not preceded by \\, or JsRender tags {{xxx}}. Each of these strings are considered
Expand Down Expand Up @@ -1224,43 +1224,43 @@ function tmplFn(markup, tmpl, isLinkExpr, convertBack, hasElse) {
}
}

function parseTag(all, bind, tagName, converter, colon, html, codeTag, params, slash, closeBlock, index) {
function parseTag(all, bind, tagName, converter, colon, html, codeTag, params, slash, bind2, closeBlock, index) {
/*
bind tagName cvt cln html code params slash closeBlk comment
/(?:{(\^)?{(?:(\w+(?=[/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{{(?:(?:\/(\w+))|!--[\s\S]*?--))}}/g
bind tagName cvt cln html code params slash bind2 closeBlk comment
/(?:{(\^)?{(?:(\w+(?=[\/\s}]))|(\w+)?(:)|(>)|(\*))\s*((?:[^}]|}(?!}))*?)(\/)?|{(\^)?{(?:(?:\/(\w+))\s*|!--[\s\S]*?--))}}/g
(?:
{(\^)?{ bind
{(\^)?{ bind
(?:
(\w+ tagName
(\w+ tagName
(?=[\/\s}])
)
|
(\w+)?(:) converter colon
(\w+)?(:) converter colon
|
(>) html
(>) html
|
(\*) codeTag
(\*) codeTag
)
\s*
( params
( params
(?:[^}]|}(?!}))*?
)
(\/)? slash
(\/)? slash
|
{{
{(\^)?{ bind2
(?:
(?:\/(\w+)) closeBlock
(?:\/(\w+))\s* closeBlock
|
!--[\s\S]*?-- comment
!--[\s\S]*?-- comment
)
)
}}/g
*/

if (codeTag && bind || slash && !tagName || params && params.slice(-1) === ":") {
if (codeTag && bind || slash && !tagName || params && params.slice(-1) === ":" || bind2) {
syntaxError(all);
}

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
@@ -1,6 +1,6 @@
{
"name": "jsrender",
"version": "v0.9.72",
"version": "v0.9.73",
"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

0 comments on commit 11ebdd8

Please sign in to comment.