diff --git a/examples/dynamic_inclusion/client/example.css b/examples/dynamic_inclusion/client/example.css new file mode 100644 index 00000000..a59ec29d --- /dev/null +++ b/examples/dynamic_inclusion/client/example.css @@ -0,0 +1,9 @@ +.panel { + background:#eee; + padding:2em; +} + +.area { + border:1px solid #aaa; + padding:2em; +} \ No newline at end of file diff --git a/examples/dynamic_inclusion/client/example.html b/examples/dynamic_inclusion/client/example.html new file mode 100644 index 00000000..b6f27a35 --- /dev/null +++ b/examples/dynamic_inclusion/client/example.html @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + diff --git a/examples/dynamic_inclusion/client/example.js b/examples/dynamic_inclusion/client/example.js new file mode 100644 index 00000000..a8d52f6c --- /dev/null +++ b/examples/dynamic_inclusion/client/example.js @@ -0,0 +1,19 @@ + + + + +Template.settings.helpers({ + + + getTemplate: function() { + + var w = window.location.href.split("/"); + + return w[4]; + } + +}); + + + + diff --git a/examples/dynamic_inclusion/router.js b/examples/dynamic_inclusion/router.js new file mode 100644 index 00000000..1dbaedb7 --- /dev/null +++ b/examples/dynamic_inclusion/router.js @@ -0,0 +1,72 @@ +/** + * Dynamic Inclusion Example + * + * This examples shows how to dynamically include templates within a wrapper in second level + * routes using only Iron Router + * + * Author: http://github.com/flyandi + */ + + +/** + * Configure the router with the base template + */ + +Router.configure({ + layoutTemplate: 'default' +}); + + +/** + * This is our first content area + */ + +Router.route('/dashboard', { + + yieldTemplates: { + 'dashboard': {to: 'body'} + }, + +}); + +/** + * This is our second route that has the second level content areas + */ + + +Router.route("/settings", function() { + + this.redirect("/settings/profile"); + +}); + + +/** + * Here we registering our second level content areas + */ + +['profile', 'billing', 'account'].forEach(function(path) { + + + Router.route('/settings/' + path, { + + yieldTemplates: { + 'settings': {to: 'body'} + }, + + template: path, + + }); + +}); + + +/** + * This is just for convience so we always start with our first route + */ + +Router.route('/', function() { + this.redirect("/dashboard"); +}); + +