pitr/angular-rails-templates — pull request #38 by whitehat101 (2014-04-29 22:51:29+00:00)
Title: Many Updates

I tried to clean up the history, but I made a lot of commits. If you want me to squash it down more, I can work on it.

Re-write Core Functionality to support all markups Tilt Supports, Template Chaining, HtmlCompressor

- If Tilt supports it, angular-rails-templates supports it
- the `.html` extension is now mandatory, it is the "template" that wraps the html into JS
- Templates can be chained (e.g.: html.haml.erb)
- common markups are autoloaded, additional markups can be loaded by adding them to config.angular_templates.markups
- If the user has the required library loaded the following formats/extensions will be added to sprockets engines: [erb haml liquid md radius slim str textile wiki]
- Rails' `to_json` and even the JSON gem had quirky behavior, so I wrote a custom `escape_javascript` that escapes with minification in mind. It counts " vs ' and escapes the one that will result in the shortest escaped string
- add support for the `htmlcompressor` gem -- disabled by default because it's not actively maintained
- MiniTest and Capybara for testing, *lots* of new tests
- inside the dummy app, include a trivial angular app that displays the number of cached templates
- update travis to test against `rails-head`

*Note:*

The `htmlcompressor` project is pretty inactive, and it pulls in an outdated YUI to compress CSS/JS that causes issues with windows, at minimum. I thought that was really gross, so [I forked it](https://github.com/whitehat101/htmlcompressor) and opened a [PR](https://github.com/paolochiodi/htmlcompressor/pull/14). I just made YUI optional (it wasn't even enabled by default). If you're putting inline javascript or css in your angular templates, you're doing it wrong.

```ruby
gem 'htmlcompressor', github: 'whitehat101/htmlcompressor'
```

*Note:*

I'm not completely sure I'm [autodetecting Tilt template engines](https://github.com/whitehat101/angular-rails-templates/blob/master/lib/angular-rails-templates/engine.rb#L9-17) in the best way. It definitely works, but with Rails 4.1 and spring, if you `spring stop; rails console` you will get warnings about thread safety. It doesn't happen with `rails server`, or anywhere else that I've seen. I'm 90% sure it's harmless as-is.