Skip to content

Commit 3c4b7b1

Browse files
committed
v1.0.11 release
Feature improvement when using JsRender in a browser, without jQuery: It is now possible to pass an ID selector for a script block to $.templates("#myTmpl"), even when using JsRender without jQuery See #363 Provide support for passing an ID selector to $.templates() even when using JsRender without jQuery Sync with other changes in v1.0.11 for JsViews
1 parent 645902a commit 3c4b7b1

18 files changed

Lines changed: 158 additions & 61 deletions

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ When jQuery is present, JsRender loads as a jQuery plugin and adds `$.views`, `$
4040

4141
#### Using JsRender without jQuery
4242

43-
When jQuery is not present, JsRender provides its own `jsrender` namespace object, exposed as `window.jsrender`
43+
When jQuery is not present, JsRender provides its own global namespace object: `jsrender` (or `window.jsrender`)
4444

4545
The `jsrender` namespace provides the same methods/APIs as with jQuery, so if jQuery is not present you can still use all the API examples, by simply writing:
4646

@@ -49,6 +49,7 @@ var $ = window.jsrender;
4949

5050
// Now use code as in samples/examples, with $.views... $.templates... $.render...
5151
```
52+
(*Note:* If jQuery is not loaded, then [passing a jQuery selector](http://www.jsviews.com/#compiletmpl@fromscriptblock) to `$.templates()` will only work for the *ID selector*)
5253

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

@@ -83,10 +84,10 @@ Name: {{:name}}
8384
then, somewhere in your script:
8485

8586
```js
86-
var tmpl = $.templates("#myTemplate");
87+
var tmpl = $.templates("#myTemplate"); // Pass in a jQuery selector for the script block
8788
```
8889

89-
On Node.js, from an .html file containing the template markup:
90+
On Node.js, [from an .html file](https://www.jsviews.com/#jsr-node-quickstart@htmlfiles) containing the template markup:
9091

9192
```js
9293
var $ = require('jsrender'); // returns the jsrender namespace object

jsrender-node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! JsRender v1.0.10: http://jsviews.com/#jsrender */
1+
/*! JsRender v1.0.11: http://jsviews.com/#jsrender */
22
/*! **VERSION FOR NODE.JS** (For WEB see http://jsviews.com/download/jsrender.js) */
33
/*
44
* Best-of-breed templating in browser or on Node.js.
@@ -20,7 +20,7 @@ if (typeof exports !== 'object' ) {
2020
//========================== Top-level vars ==========================
2121

2222
// global var is the this object, which is window when running in the usual browser environment
23-
var versionNumber = "v1.0.10",
23+
var versionNumber = "v1.0.11",
2424
$, jsvStoreName, rTag, rTmplString, topView, $views,
2525
_ocp = "_ocp", // Observable contextual parameter
2626

@@ -726,7 +726,7 @@ function renderTag(tagName, parentView, tmpl, tagCtxs, isUpdate, onError) {
726726
tag.linkCtx = linkCtx;
727727
if (tag._.bnd = boundTag || linkCtx.fn) {
728728
// Bound if {^{tag...}} or data-link="{tag...}"
729-
tag._.ths = tagCtx.params.props.this; // Tag has a this=expr binding, to get javascript reference to tag instance
729+
tag._.ths = tagCtx.params.props["this"]; // Tag has a this=expr binding, to get javascript reference to tag instance
730730
tag._.lt = tagCtxs.lt; // If a late path @some.path has not returned @some object, mark tag as late
731731
tag._.arrVws = {};
732732
} else if (tag.dataBoundOnly) {

jsrender.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! JsRender v1.0.10: http://jsviews.com/#jsrender */
1+
/*! JsRender v1.0.11: http://jsviews.com/#jsrender */
22
/*! **VERSION FOR WEB** (For NODE.JS see http://jsviews.com/download/jsrender-node.js) */
33
/*
44
* Best-of-breed templating in browser or on Node.js.
@@ -44,7 +44,7 @@ var setGlobals = $ === false; // Only set globals if script block in browser (no
4444

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

47-
var versionNumber = "v1.0.10",
47+
var versionNumber = "v1.0.11",
4848
jsvStoreName, rTag, rTmplString, topView, $views, $expando,
4949
_ocp = "_ocp", // Observable contextual parameter
5050

@@ -753,7 +753,7 @@ function renderTag(tagName, parentView, tmpl, tagCtxs, isUpdate, onError) {
753753
tag.linkCtx = linkCtx;
754754
if (tag._.bnd = boundTag || linkCtx.fn) {
755755
// Bound if {^{tag...}} or data-link="{tag...}"
756-
tag._.ths = tagCtx.params.props.this; // Tag has a this=expr binding, to get javascript reference to tag instance
756+
tag._.ths = tagCtx.params.props["this"]; // Tag has a this=expr binding, to get javascript reference to tag instance
757757
tag._.lt = tagCtxs.lt; // If a late path @some.path has not returned @some object, mark tag as late
758758
tag._.arrVws = {};
759759
} else if (tag.dataBoundOnly) {
@@ -1115,6 +1115,8 @@ function compileTmpl(name, tmpl, parentTmpl, options) {
11151115
// Look for server-generated script block with id "./some/file.html"
11161116
elem = document.getElementById(value);
11171117
}
1118+
} else if (value.charAt(0) === "#") {
1119+
elem = document.getElementById(value.slice(1));
11181120
} else if ($.fn && !$sub.rTmpl.test(value)) {
11191121
try {
11201122
elem = $(value, document)[0]; // if jQuery is loaded, test for selector returning elements, and get first element

jsrender.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsrender.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsrender",
3-
"version": "v1.0.10",
3+
"version": "v1.0.11",
44
"description": "Best-of-breed templating in browser or on Node.js (with Express 4, Hapi and Browserify integration)",
55
"main": "./jsrender-node.js",
66
"browser": "./jsrender.js",

test/browserify/bundles/1-bundle.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browserify/bundles/12-nested-bundle.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browserify/bundles/2-bundle.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browserify/bundles/3-bundle.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)