Skip to content

Commit

Permalink
Commit 65 (v1.0.0-rc.65 - Release Candidate)
Browse files Browse the repository at this point in the history
BREAKING CHANGES AND IMPROVEMENTS

- The global namespace when JsRender is loaded without jQuery
  is now window.jsrender. (Previously it was window.jsviews).
  So when using JsRender without jQuery, you can write:
  var $ = jsrender; - and use the $ var it in the same way you
  would use the global $ when JsRender is loaded with jQuery:
  e.g. $.templates(...) or $.views.helpers(...) etc.

- AMD support has been improved and simplified. All AMD
  modules, including JsRender, with or without jQuery, now
  return the jQuery object (if loaded) or the analogous
  JsViews object.

- Node.js support and integration has been improved - along
  with improved CommonJS support, and Browserify integration.
  The file system APIs now use the syntax tmpl="./file/path.html".
  The Node.js version of jsrender.js is available as a separate
  file (available at //jsviews.com/download/jsrender-node.js).

  The Node.js version of JsRender provides the complete set of
  JsRender APIs and features, together with integration
  with NodeJS view-engines such as Express and Hapi, APIs
  for loading templates from the file system, etc.
  The file system APIs now use the syntax tmpl="./file/path.html".

  It also includes a built-in Browserify transform (see "Browserify
  Support: below).

  (Note: JsRender and JsViews will soon be published to NPM).

- The behavior when loading multiple instances of JsRender or
  JsViews files has been changed: When loading a new instance,
  the previous instance $.views, $.templates, etc. is no longer
  overwritten. So a component using JsRender or JsViews will not,
  when loaded, cause another already loaded component also using
  JsViews/JsRender to fail (except for collisions arising in the
  unlikely case where both happen to use the same
  template/converter/helper name).

  As part of this modified behavior, the noConflict support
  for JsRender had been removed.

NEW FEATURES

- Browserify Support:
  JsRender on Node.js provides a built-in Browserify
  transform - jsrender.tmplify, for including compiled JsRender
  templates from the server, as part of the client javascript
  bundle generated by Browserify.

  Usage example:

  var $jsr = require('jsrender');

  browserify(...) ... .transform($jsr.tmplify) ...
  See also http://www.jsviews.com/test/unit-tests-browserify.html

- Initial work for deployment to Bower and NPM. See
  BorisMoore/jsviews#254
  #225

Bug Fixes:

- #263
  #264
  Caching of template on script elements. (Unit tests
  added)
  • Loading branch information
BorisMoore committed Aug 18, 2015
1 parent 7c0b660 commit e7cdb9f
Show file tree
Hide file tree
Showing 30 changed files with 4,518 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/.*
node_modules
bower_components
test/browserify/bundles/*.js
*.config
Scripts
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**/.*

/test/browserify/bundles/*.js
*.config
gulpfile.js

/Scripts
/node_modules
/bower_components
/demos
/test
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## JsRender: best-of-breed templating
_Simple and intuitive, powerful and extensible, lightning fast_<br/>
_For templated content in the browser or on Node.js (with Express 4, Hapi and Browserify integration)_<br/>

**JsRender** is a light-weight but powerful templating engine, highly extensible, and optimized for high-performance pure string-based rendering, without DOM or jQuery dependency.
**JsRender** is a light-weight but powerful templating engine, highly extensible, and optimized for high-performance pure string-based rendering, without DOM or jQuery dependency (but with powerful optional jQuery integration).

**JSRender** and **JsViews** together provide the next-generation implementation of both _JQuery Templates_, and _JQuery Data Link_ - and supersede those libraries.

Expand All @@ -22,4 +23,4 @@ see also:
- the [demos](https://github.com/BorisMoore/jsviews/tree/master/demos) folder of the JsViews GitHub repository - or [here](http://borismoore.github.io/jsviews/demos/index.html) as live samples.

<h3>Current Status</h3>
JsRender is now a beta release, currently moving towards V1.0.
JsRender is now a V1.0 release candidate.
43 changes: 43 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "jsrender",
"main": "jsrender.js",
"homepage": "http://www.jsviews.com/#jsrender",
"authors": [
{
"name": "Boris Moore",
"email": "[email protected]",
"homepage": "https://github.com/borismoore"
}
],
"description": "Best-of-breed templating in browser or on Node.js (with Express 4, Hapi and Browserify integration)",
"moduleType": [
"amd",
"globals",
"node"
],
"repository": {
"type": "git",
"url": "git://github.com/borismoore/jsrender.git"
},
"keywords": [
"jsrender",
"jquery",
"node",
"express",
"hapi",
"browserify",
"templates",
"template"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"demos",
"*.md",
"gulpfile.js",
"package.json"
]
}
10 changes: 5 additions & 5 deletions demos/scenarios/02_separators-scenario.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ <h3>Example Scenario: Inserting "and" and "," separators between words</h3>
</table>
<br />

<!---------------------- Second Example ---------------------->
<!---------------------- Third Example ---------------------->

<div class="subhead">Example 2: Custom helper functions:</div>
<div class="subhead">Example 3: Custom helper functions:</div>

<pre>
{{for languages}}
Expand All @@ -99,7 +99,7 @@ <h3>Example Scenario: Inserting "and" and "," separators between words</h3>
</table>
<br />

<!---------------------- Third Example ---------------------->
<!---------------------- Fourth Example ---------------------->

<h3>Using "allowCode"</h3>

Expand All @@ -109,7 +109,7 @@ <h3>Using "allowCode"</h3>
<br /><br />The following two examples illustrate its use, but are not the recommended approach. The built-in expression support,
<br />custom tags, helper functions etc. provide a better solution for almost all scenarios, as in the two examples above.</div>

<div class="subhead">Example 3: allowCode, for program flow - with if(...) { ... }:</div>
<div class="subhead">Example 4: allowCode, for program flow - with if(...) { ... }:</div>

<pre>
$.templates( "movieTmpl", {
Expand Down Expand Up @@ -150,7 +150,7 @@ <h3>Using "allowCode"</h3>
<tbody id="movieList4"></tbody>
</table>

<!---------------------- Fourth Example ---------------------->
<!---------------------- Fifth Example ---------------------->

<div class="subhead">Example 5: allowCode, for returning content - with ternary expression:</div>

Expand Down
26 changes: 26 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var gulp = require('gulp'),
browserify = require('browserify'),
fs = require('fs');

//================================= BUNDLE - Run Browserify - create client bundles for test cases =================================//
// See https://github.com/gulpjs/gulp/blob/master/docs/recipes/browserify-with-globs.md

// Task to create Browserify client-side bundle scripts for Browserify test cases.
gulp.task('bundle', function() {
var $jsr = require('./index.js');
var gs = require('glob-stream');

return gs.create('./test/browserify/*-unit-tests.js')
.on('data', function(file) {
// file has path, base, and cwd attrs
var fileName = file.path.slice(file.base.length, -14);
browserify(file.path, {debug:true})
.transform($jsr.tmplify)
.bundle()
.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
});
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*! JsRender
* Version for web: jsrender.js
* Version for Node.js: jsrender-node.js
*/

'use strict';

module.exports = require('./jsrender-node.js');
6 changes: 6 additions & 0 deletions index.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit e7cdb9f

Please sign in to comment.