I just inherited a project with node.js/express written in coffeescript and using jade to render views. In my views folder I have about 20 jade files that need to have routes set up. Rather than repeat myself over and over like so (which is currently working just fine):
app.get '/html/404.html', (req,res) ->
res.render '404',
app.get '/html/503.html', (req,res) ->
res.render '503',
app.get '/html/foo.html', (req,res) ->
res.render 'foo',
I'd prefer to keep this less messy by creating an array of the urls and using a for loop to iterate over it, something like this:
urls = [
"404"
"503"
"foo"
]
for url in urls
app.get "/html/#{url}.html", (req,res) ->
res.render "#{url}",
Unfortunately this isn't working. Any advice?