Skip to content

Instantly share code, notes, and snippets.

@Primigenus
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Primigenus/f9451c2b7a4fa77b8b35 to your computer and use it in GitHub Desktop.
Save Primigenus/f9451c2b7a4fa77b8b35 to your computer and use it in GitHub Desktop.
An attempt at mocking a drastic simplification of routing in Meteor
<template name="posts" url="/posts" lang="en" layout="main">
{{#contentFor region="header"}}
<h1>Posts</h1>
{{/contentFor}}
{{#contentFor region="body"}}
<article>
{{#each posts}}
<p>{{title}}</p>
{{/each}}
</article>
{{/contentFor}}
{{#contentFor region="footer"}}
<div>...</div>
{{/contentFor}}
</template>
<layout name="main">
<header>{{#region name="header" /}}</header>
<div>{{#region name="body"}}</div>
<footer>{{#region name="footer" /}}</footer>
</layout>
Template.posts.helpers({
posts: function() {
return Posts.find();
}
});
Template.posts.routing({
runBefore: function() {
// this = template instance
if (Meteor.isClient)
Session.set("page", "posts");
},
runAfter: function() {
Meteor.call("checkTumblr");
},
waitOnSubs: function() {
return [
Meteor.subscribe("posts");
];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment