ostrio:iron-router-title

v1.0.0Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Reactive page title for meteor within iron-router

Change document.title on the fly within iron-router

This package supports title option defined in list below, ordered by prioritization:

  • Router.route() [overrides all]
  • RouteController.extend()
  • Router.configure() [might be overridden by any above]

Install:

meteor add ostrio:iron-router-title

Usage:

Set title property in router's or controller's configuration:

1# Set default document.title value in 
2# case router has no title property
3Router.configure
4  title: 'Default title'
5
6Router.route 'account',
7  template: 'account'
8  path: '/me/account'
9  title: 'My Account'
10
11LocationController = RouteController.extend(title: "Location Title")
12Router.route 'locations', controller: LocationController

Use function context:

1Router.route 'account',
2  template: 'account'
3  path: '/me/account/:_id'
4  title: ->
5    "Account of #{@data().getFullName()}"
6  data: ->
7    getFullName: =>
8      Meteor.users.findOne(@params._id).fullName

To change title reactively, just pass it as function:

1Router.route 'account',
2  template: 'account'
3  path: '/me/account'
4  title: () ->
5    i18n.get 'account.document.title'

In this example we used ostrio:i18n package