Skip to content

Template helpers for meteorhacks:flow-router, pathFor, subsReady, urlFor, queryParam

License

Notifications You must be signed in to change notification settings

adrprado/meteor-flow-router-helpers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Helpers for FlowRouter

Template helpers for kadira:flow-router

  • subsReady
  • isSubReady (deprecated)
  • pathFor
  • urlFor
  • param
  • queryParam
  • currentRouteName

See zimme:active-route for using the following helpers

  • isActiveRoute
  • isActivePath
  • isNotActiveRoute
  • isNotActivePath

Install

meteor add arillo:flow-router-helpers

Usage subsReady

Checks whether your subscriptions are ready. You can pass multiple subscription names. If you don't pass a subscription name it will check for all subscriptions to be ready.

{{#if subsReady 'items' 'posts'}}
  <ul>
  {{#each items}}
    <li>{{title}}</li>
  {{/each}}
  </ul>
  <ul>
  {{#each posts}}
    <li>{{title}}</li>
  {{/each}}
  </ul>
{{/if}}

Usage isSubReady (deprecated)

Checks whether your subscription is ready. If you don't pass a subscription name it will check for all subscriptions.

{{#if isSubReady 'items'}}
  <ul>
  {{#each items}}
    <li>{{title}}</li>
  {{/each}}
  </ul>
{{/if}}

Usage pathFor

Used to build a path to your route. First parameter can be either the path definition or, since version 1.2.0 of flow-router, the name you assigned the route. After that you can pass the params needed to construct the path. Query parameters can be passed with the query parameter.

Notice: To deparameterize the query string we are currently using the not yet official accessor for the query lib in page.js via FlowRouter._qs

<a href="{{pathFor '/post/:id' id=_id}}">Link to post</a>
<a href="{{pathFor 'postRouteName' id=_id}}">Link to post</a>
<a href="{{pathFor '/post/:id/comments/:cid' id=_id cid=comment._id}}">Link to comment in post</a>
<a href="{{pathFor '/post/:id/comments/:cid' id=_id cid=comment._id query='back=yes&more=true'}}">Link to comment in post with query params</a>

Usage urlFor

Same as pathFor, returns absolute URL.

{{urlFor '/post/:id' id=_id}}

Usage param

Returns the value for a url parameter

<div>ID of this post is <em>{{param 'id'}}</em></div>

Usage queryParam

Returns the value for a query parameter

<input placeholder="Search" value="{{queryParam 'query'}}">

Usage currentRouteName

Returns the name of the current route

<div class={{currentRouteName}}>
  ...
</div>

Changelog:

0.4.4 - added currentRouteName helper
0.4.3 - added param helper
0.4.0 - updated to use kadira:flow-router
0.3.0 - changed isSubReady in favor of subsReady

About

Template helpers for meteorhacks:flow-router, pathFor, subsReady, urlFor, queryParam

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%