Skip to content
This repository

A lightweight but powerful templating engine, highly extensible, without DOM or jQuery dependency.

branch: master

Commit 52 (Post Beta)

Note that this update brings significant feature improvements
with corresponding changes to the implementation. For normal
usage patterns these do not correspond to breaking changes. However
there could possibly be breaking changes on a few advanced scenarios.
If appropriate, please file issues if breaking changes are
observed. See also the samples and unit tests for changes that take
advantage of new features below.

New features and improvements
- {{: xxx}} can now be used without arguments, so {{:}} is equivalent
  to {{:#data}}. This is a similar pattern to {{for}} {{include}} etc.

- autoBind feature for custom tags allows a custom tag without
  argument to bind to current data context, so {{mytag/}} is
  equivalent to {{mytag #data/}}. This is achieved by setting
  autoBind: true on the tag definition.

- Can now define a converter for the first arg on any tag - custom
  or built-in. e.g. {{for myarray convert=~reverseArray}}
  or {{mycustomtag name convert='someRegisteredConverter'/}}
  or <div data-link="name convert=formatName" /}} (in this example
  the person object has a name property and a formatName method)

- Similarly any tag with two-way binding can have a convertBack
  converter:
  e.g. <input data-link="name convert=~SomeHelper convertBack=SomeMethodOnDataObject" />
  or {^{slider speed convert=~fromMphToKmH convertBack=fromKmHtoMph/}}
  or: {^{myTextBoxTag convert=~myCnvtHelper convertBack='myregisteredConverter'/}}

- Improved support for rendering arrays without iteration:
  render(array, helpers) will iterate over the array, but you can
  now pass a 'noIteration' boolean. So render(array, true) renders
  anv array without iteration, and similarly, render(array, helpers, true)
  now renders an array without iteration while passing in helpers.

  Within methods and events of custom tags:
  tagCtx.render() renders against the current data object,
  tagCtx.render(someArray) iterates over the array
  tagCtx.render(someArray, true) or tagCtx.render(someArray, helpers, true)
  renders without iteration.

- In a custom tag, a template can now be assigned (determined
  dynamically) in the init method simply by setting:
  this.template = templateObjectOrMarkupString;
  It is no longer necessary to write:
  this.template = tagCtx.tmpl = templateObjectOrMarkupString;

- Support for declaring event handlers directly on tags or
  data-link expressions: {{anyTag onXxx=myXxxHandler /}}
  This can be used for standard event handlers such as onUpdate,
  onBeforeChange etc.
  e.g. <textarea data-link="text onUpdate=updateMethodOnViewModelObject"></textarea>

- There is a new helper utility function for validation of
  HTML markup in JsViews: $.views.utility.validate(markupString)
  This could be used in the following example:
  $.views.helpers("validateMarkup", $.views.utility.validate);
  <textarea data-link="text onBeforeChange=~validateMarkup"></textarea>

- Improved error message if JsViews or JsObservable is loaded without jQuery

Bug fixes:
- Fix for #231

- Fix for a memory leak issue

- Fixes for some issues with radio buttons and with multiselect

- Fixes for bugs in some samples
latest commit 22fa956c7e
Boris Moore authored
Octocat-spinner-32 demos Commit 52 (Post Beta) March 25, 2014
Octocat-spinner-32 test Commit 52 (Post Beta) March 25, 2014
Octocat-spinner-32 MIT-LICENSE.txt Final commit for official JsRender Beta release. (Simultaneous with the June 10, 2013
Octocat-spinner-32 README.md Commit 42 (post beta) September 22, 2013
Octocat-spinner-32 jsrender.js Commit 52 (Post Beta) March 25, 2014
Octocat-spinner-32 jsrender.min.js Commit 52 (Post Beta) March 25, 2014
Octocat-spinner-32 jsrender.min.js.map Commit 52 (Post Beta) March 25, 2014
README.md

JsRender: best-of-breed templating

Simple and intuitive, powerful and extensible, lightning fast

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 and JsViews together provide the next-generation implementation of both JQuery Templates, and JQuery Data Link - and supersede those libraries.

Documentation and Downloads

Documentation, downloads, samples and API docs and tutorials are available on the www.jsviews.com website.
(Stay tuned at www.jsviews.com for additional content - coming incrementally as we move towards V1.0)

JsRender and JsViews

JsRender is used for rendering of templates to strings, ready for insertion in the DOM.
It is also used by the 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.

Demos

In addition to the demos at www.jsviews.com/#samples, and throughout the API documentation, see also:

  • the demos folder of this GitHub repository - available here as live samples.
  • the demos folder of the JsViews GitHub repository - or here as live samples.

Current Status

JsRender is now a beta release, currently moving towards V1.0.

Something went wrong with that request. Please try again.