CityWebConsultants / Iris

Modular content management and web application framework built with Node.js and MongoDB
http://irisjs.org
Other
9 stars 7 forks source link

Server-rendered Handlebars templates -> client side live update #223

Closed FilipNest closed 8 years ago

FilipNest commented 8 years ago

Creates an {{{{iris_liveupdate}}}} Handlebars block helper that wraps a Handlebars entity template (loaded through iris entity embeds), renders it normally on the server side but also makes the template available for live entity updates on the client side without having to duplicate or use Angular.js .

Example:


<!-- Load a page with eid 1 into the "page" Handlebars variable as before -->
[[[entity page,{"entities":["page"], "queries":[{"value":"1","operator":"is","field":"eid"}]}]]]

<!-- Wrap the use of this Handlebars variable in the iris_liveupdate block -->
<!-- Rendered as before but changes when an entity update occurs -->
<!-- Permission checks etc as before just goes through client side templates.js -->

  {{{{iris_liveupdate}}}} 
    {{page.0.title}} 
  {{{page.0.body}}} 
  {{{{/iris_liveupdate}}}} 

This removes the need for the Angular JS liveload module (can move to contrib for those wanting to use Angular) and finally gives us server-rendered templates that live update (the dream I've been aiming for for at least a year, probably more now). If you weren't using any other Handlebars variables (they'd be lost on update due to the client side not having access to them) you could easily wrap a whole page in this if you wanted it to live update. Probably best to leave for comments and other dynamic content though.

adam-clarey commented 8 years ago

Could this functionality be added to the wiki?