view.js 655 B

123456789101112131415161718192021
  1. (function (App, settings) {
  2. // define globals for template dsl
  3. App.templates.options = require('extend')(App.templates.options, {
  4. globals: function (file) { return {
  5. emit: function () { return __.util.emit.apply(null, arguments) },
  6. h: function () { return __.util.h.apply(null, arguments) } } } });
  7. // start view
  8. var view = require('riko-mvc').V(App.model,
  9. function (state) { return App.templates().app(state) });
  10. document.body.innerHTML = "";
  11. document.body.appendChild(view.target);
  12. // update view if templates are edited
  13. App.templates.events.onAny(function () { view.update(App.model()) });
  14. return view;
  15. })