Reputation: 3869
I'm trying to implement this route:
@route "buildingSpaceTenant",
path: "/buildings/:_building_id/spaces/:_space_id/tenants/:_id/communications"
template: "tenant"
yieldTemplates: {
Session.get("current_tenant_subtemplate"): {to: "subTemplate"}
}
but apparently I can't use the session object this way.
<runJavaScript-30>:148:11: client/routes/tenantsRoute.coffee:44: unexpected . (compiling client/routes/tenantsRoute.coffee) (at handler)
What's the right way?
Upvotes: 0
Views: 193
Reputation: 64312
You can't use variable names as keys in an object literal. If yieldTemplates
can accept a function (I don't think it can), you could try something like:
@route 'buildingSpaceTenant',
path: '/buildings/:_building_id/spaces/:_space_id/tenants/:_id/communications'
template: 'tenant'
yieldTemplates: ->
templateName = Session.get 'current_tenant_subtemplate'
obj = {}
obj[templateName] = to: 'subTemplate'
obj
I had a look at the example from this issue which implies that you could try overriding action
to achieve the same end result.
@route 'buildingSpaceTenant',
path: '/buildings/:_building_id/spaces/:_space_id/tenants/:_id/communications'
template: 'tenant'
action: ->
if @ready()
@render()
templateName = Session.get 'current_tenant_subtemplate'
@render templateName, to: 'subTemplate'
else
@render 'loading'
Give those ideas a try and let me know how it goes.
Upvotes: 1