Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility issues with asset-rack #30

Open
max-degterev opened this issue Jul 14, 2013 · 2 comments
Open

compatibility issues with asset-rack #30

max-degterev opened this issue Jul 14, 2013 · 2 comments
Labels

Comments

@max-degterev
Copy link

It looks like if you instantiate poet before modules that affect express "local" templating scope they fail to initialize properly

An example.

Works:

# Middleware
app.use(assets)
app.use(express.static(__dirname + '/public'))

# Global vars for templates
app.locals.pretty = config.debug
app.locals.helpers = require('./app/helpers') # template helpers etc
app.locals.__env =
  hostname: config.hostname
  debug: config.debug
  ga_id: config.ga_id
  version: require('./package').version

poet = Poet(app,
  postsPerPage: config.blog.per_page
  posts: __dirname + '/posts'
  metaFormat: 'json'
  routes:
    '/blog/read/:post':   'post'
    '/blog/:page':        'page'
    '/blog/tag/:tag':     'tag'
)

# Init routing
poet.init()
app.use(app.router)
server.initialize(app)

Fails:

poet = Poet(app,
  postsPerPage: config.blog.per_page
  posts: __dirname + '/posts'
  metaFormat: 'json'
  routes:
    '/blog/read/:post':   'post'
    '/blog/:page':        'page'
    '/blog/tag/:tag':     'tag'
)

# Middleware
app.use(assets)
app.use(express.static(__dirname + '/public'))

# Global vars for templates
app.locals.pretty = config.debug
app.locals.helpers = require('./app/helpers') # template helpers etc
app.locals.__env =
  hostname: config.hostname
  debug: config.debug
  ga_id: config.ga_id
  version: require('./package').version

# Init routing
poet.init()
app.use(app.router)
server.initialize(app)
@jsantell
Copy link
Owner

What fails to initialize properly? The locals (__env, pretty, helpers) are not found in the view templates?

@max-degterev
Copy link
Author

asset-rack passes asset object that has methods like asset.tag(filename) to create tags etc. if poet doesnt go last its undefined. Of course you can always re-assing it to locals later. I switched to grunt because it allows greater control over assets compilation so its no longer an issue to me. https://github.com/techpines/asset-rack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants