I am building a Sammy application and I want to use Haml for it. Looks good so far.
app = $.sammy '#main', ->
@use 'Haml'
# Get some server data
$.getJSON '/some-data', (data) ->
# Hic sunt ponies
@get '#!/', ->
@partial '/tmpl/maintenance.haml'
@
$ -> app.run '#!/'
I have a template /tmpl/navbar.haml that I would like to render before any routing. The reason for this is, the navbar is dependant on some data I receive from the server – again, before the routing.
So how can I render the template outside of the route? Sammy doesn’t seem to have a method read for this, only inside a RenderContext, e.g. a route.
I used ‘location-changed’ event, may be not ideal, but seems working:
Where app.connected is session check. And ‘#welcome’ is outside of sammy’s $element, and should be present.
You can use context.load for template.