solidusjs / solidus

A simple server that generates pages from JSON and Templates
MIT License
28 stars 7 forks source link

Dynamic segments can't contain dashes #83

Open pushred opened 10 years ago

pushred commented 10 years ago

I think this issue is more about answering the question of what characters are not allowed in view filenames, including dynamic segments. Currently given a filename like {album-id.hbs} the router throws an exception. At the very least there should be some feedback in the log that a character threw it off.

Dashes aren't reserved in common filesystems, but they don't work in JavaScript's dot notation, so maybe it's good to not support dashes. The filenames of route segments are used as keys in the parameters object. It does seem that Handlebars supports bracket notation, so parameters[two-words] should be valid however.

@vic3685

Fauntleroy commented 10 years ago

Probably has something to do with this: https://github.com/SparkartGroupInc/solidus/blob/master/lib/page.js#L60

Fauntleroy commented 10 years ago

Alright it looks like the issue has to do with the fact that I'm making express route strings, and I'm not sure if it picks up dashes and underscores in variable names. This might take some doing.

Fauntleroy commented 10 years ago

It doesn't look like I can use a custom regular expression with keywords! There MIGHT still be some way for me to do it manually, but it could take some time. For now we might just want to avoid... using dashes in there. You can always use an underscore!

Fauntleroy commented 10 years ago

Note for @joanniclaborde

This is one of those issues that makes me think that using express for Solidus might not be the right approach. Express includes a great deal of functionality, and we're using it in a somewhat creative way. We might want to use something lower level, and possible multiple modules (http server, routing, middleware, etc) instead of one.

pushred commented 10 years ago

Express 4 came out recently, with some big changes to routing. It's also broken away from Connect. Have you seen koa? Is Connect starting to fall out of favor?

The big challenge to switching away from Express would probably be finding a suitably mature replacement for the Handlebars view engine. At least it's being maintained and works in Express 4.

Fauntleroy commented 10 years ago

It doesn't really seem like Connect has fallen out of favor per-se, just that they're not basing Express on it anymore. The middleware seems like it should still work, it's just not auto bundled. I think they're just working on making Express more modular, and splitting out dependencies into their own independent modules.

I've seen koa, but I've only glanced over it. It uses some node.js features that are still experimental and is not ready for production use.