Last active
August 29, 2015 14:10
-
-
Save Primigenus/f9451c2b7a4fa77b8b35 to your computer and use it in GitHub Desktop.
An attempt at mocking a drastic simplification of routing in Meteor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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