craigspaeth/nap — pull request #51 by ragulka (2013-04-03 08:14:20+00:00)
Title: Precompiling mixed handlebars and jade templates

I'm mixing jade with handlebars so that I don't have to write HTML. For example, I have a template called invoices/invoicerow.handlebars.jade and it looks like this:

```jade
tr
td.title {{title}}
td.price {{price}}
td.quantity {{quantity}}
td.discountRate {{discountRate}}
td.taxRate {{taxRate}}
td.total {{total}}
```

I have extended nap templateParses with this function:
```javascript
nap.templateParsers['.handlebars.jade'] = function(contents) {
contents = jade.compile(contents);
return "Handlebars.template(" + Handlebars.precompile( contents ) + ")";
};
```

The only problem is that my .handlebars.jade templates are just being compiled into jade - and it happens because nap is extracting the extension from the template filenames: https://github.com/craigspaeth/nap/blob/master/lib/nap.coffee#L270

Now, I could just use a custom file extension for my case, but that would mean that I lose syntax highlighting and I do not like the semantics of something like template.hbsjade

One solution would be to check if the filename ends with one of the extensions that the templateParses use, moving from more specific to less specific (ie check .handlebars.jade first, then .jade) and choose the template parser accordingly.

I'm not sure if this is something that You want to support, but I think it would be nice.