Skip to content

Commit

Permalink
Commit 90 (v0.9.90 - Beta)
Browse files Browse the repository at this point in the history
Sync with changes in v0.9.90 for JsViews

Minor bug fixes, including:

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  #333

Minor change for custom tags:

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Some additional unit tests
  • Loading branch information
BorisMoore committed Nov 29, 2017
1 parent 986c3a8 commit d046653
Show file tree
Hide file tree
Showing 13 changed files with 897 additions and 4,132 deletions.
195 changes: 106 additions & 89 deletions jsrender-node.js

Large diffs are not rendered by default.

195 changes: 106 additions & 89 deletions jsrender.js

Large diffs are not rendered by default.

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.

3,411 changes: 0 additions & 3,411 deletions package-lock.json

This file was deleted.

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": "v0.9.89",
"version": "v0.9.90",
"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
197 changes: 107 additions & 90 deletions test/browserify/bundles/1-bundle.js

Large diffs are not rendered by default.

197 changes: 107 additions & 90 deletions test/browserify/bundles/12-nested-bundle.js

Large diffs are not rendered by default.

197 changes: 107 additions & 90 deletions test/browserify/bundles/2-bundle.js

Large diffs are not rendered by default.

197 changes: 107 additions & 90 deletions test/browserify/bundles/3-bundle.js

Large diffs are not rendered by default.

195 changes: 106 additions & 89 deletions test/browserify/bundles/htm-jsrender-tmpl-bundle.js

Large diffs are not rendered by default.

195 changes: 106 additions & 89 deletions test/browserify/bundles/html-jsr-tmpl-bundle.js

Large diffs are not rendered by default.

42 changes: 41 additions & 1 deletion test/unit-tests/tests-jsrender-no-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,49 @@ test("", function() {
equal(!tmpl.useViews && tmpl.render({towns: towns}), "Seattle, Paris and Delhi",
"Setting $.views.settings.advanced({useViews: true}) WILL prevent a simpler template from rendering without views.");

// =========================== Reset settings ============================
$.views.settings.advanced({useViews: false});
$.views.settings.allowCode(false);
document.title = "";

// =============================== Arrange ===============================
var tmpl = $.templates("{{:a.getHtml()}} {{if true}}{{:b}} {{/if}}"),
innerTmpl = $.templates("{{:inner}}"),

data = {
a: {
getHtml: function() {
return $.templates("{{:inner}}").render(this);
},
inner: "INNER"
},
b: "OUTER"
};

// ................................ Act ..................................
html = tmpl.render(data);

// ................................ Assert ..................................
equal(!tmpl.useViews && !innerTmpl.useViews && html, "INNER OUTER ",
"Nested top-level programmatic template calls which do not use views work correctly");
// See https://github.com/BorisMoore/jsrender/issues/333

// ................................ Act ..................................
tmpl = $.templates({
markup: "{{:a.getHtml()}} {{if true}}{{:b}} {{/if}}",
useViews: true
});
innerTmpl = $.templates({
markup: "{{:inner}}",
useViews: true
});
html = tmpl.render(data);

// ................................ Assert ..................................
equal(tmpl.useViews && innerTmpl.useViews && html, "INNER OUTER ",
"Nested top-level programmatic template calls using views work correctly");
// See https://github.com/BorisMoore/jsrender/issues/333

});

QUnit.module("All tags");
Expand Down Expand Up @@ -1317,7 +1357,7 @@ test("{{sometag convert=converter}}", function() {

equal($.templates("1{{:#data convert='loc'}} 2{{:'desktop' convert='loc'}} 3{{:#data convert=~myloc}} 4{{:'desktop' convert=~myloc}}").render("desktop", {myloc: loc}), "1bureau 2bureau 3bureau 4bureau", "{{: convert=~myconverter}}");
equal($.templates("1:{{:'a<b' convert=~myloc}} 2:{{> 'a<b'}} 3:{{html: 'a<b' convert=~myloc}} 4:{{> 'a<b' convert=~myloc}} 5:{{attr: 'a<b' convert=~myloc}}").render(1, {myloc: loc}),
"1:a moins <que b 2:a&lt;b 3:a&lt;b 4:a&lt;b 5:a&lt;b",
"1:a moins <que b 2:a&lt;b 3:a&lt;b 4:a&lt;b 5:a moins <que b",
"{{foo: convert=~myconverter}} convert=converter is used rather than {{foo:, but with {{html: convert=~myconverter}}" +
"\nor {{> convert=~myconverter}} html converter takes precedence and ~myconverter is ignored");
equal($.templates("{{if true convert=~invert}}yes{{else false convert=~invert}}no{{else}}neither{{/if}}").render('desktop', {invert: function(val) {return !val;}}), "no", "{{if expression convert=~myconverter}}...{{else expression2 convert=~myconverter}}... ");
Expand Down

0 comments on commit d046653

Please sign in to comment.