cif/handlebar-rider — pull request #8 by piercemoore (2013-02-26 02:31:49+00:00)
Title: Async time :D And other goodies.

Disclaimer
---
I really want to make sure that I am not offending you by massively refactoring. This plugin is awesome, and I want to make sure you know that I am not trying to be an asshole. :+1:

This one is the big one, I think. I still have a bit more work to do with regard to making the `readTemplatesDirectory()` function async, but I got the other two all set up and DAMN it's fast. I'm **very** excited to see if there is any noticeable performance gain on your end with 150-200+ template files.

Additionally:

1) I fully finished the enabling of `n` number of additional file extensions in the command line so that a developer can specify additional file types to be compiled.

````
handlebar-rider -i "./blah" -o "./blah.js" -e tpl -e mustache -e template -e anythingyouwant
````

2) You can now specify the `-f` or `--force` flag, which will cause **all** files in the watched directory tree to be compiled. This should only be done if you know that there are only Handlebars templates in the tree, which is usually the case. The idea is that now instead of running hundreds of regex'es and string detection and finding inside arrays, we can just compile them and trust. Which *should* bring some additional performance gain.

3) I also disabled (by default) the stripping of comments from the compiled templates. This is where I think a *large* part of the performance gain will be, as the sheer amount of regex `.replace()`'s that are being skipped now is tremendous. The thinking is that if the user wants readable output, then they realistically would like the comments to stay. And if they're minifying, then `uglify.js` automatically handles the stripping of those during minification :)

4) I substituted a bunch of `indexOf('blah')`'s that were in there to determine filetype in favor of Node's native `path()` module. I'm actually kind of excited it worked out as well as it did. I'm eager to know what you think on that.

All in all, this is a huge pull request. I know I should probably break them into separate ones but I figure it's not that big of a deal. I'm **really** eager to see what you think and hope that it works out as well for you as it has for me.

Let me know!! :D