RailsTidy is a Ruby On Rails plugin that helps in organizing code and syntax to make it easy to read and maintain.
In order to use RailsTidy, it is necessary to meet a few requirements. Firstly, users will need to have Tidy, the popular HTML validator. Secondly, RubyTidy, which provides Ruby bindings for Tidy, will need to be installed as well. The installation process is straightforward, as users simply need to unpack the plugin into the vendor/plugin folder.
The Ruby bindings for libtidy will need to know the path to the file libtidy.so. In most cases, this file can be found at /usr/lib/libtidy.so. However, if this is not the case, users can add RailsTidy.tidy_path = "/path/to/your/libtidy.so" to their environment file.
When it comes to configuration, if the file config/tidy.rc exists, RailsTidy will use it to configure Tidy. If you want to use another file, you can put RailsTidy.tidy_configuration = "/path/to/a/tidy/configuration/file" in your environment file.
Using RailsTidy is also relatively simple. For validating templates, users can simply use $ rake test_templates. By default, the plugin will parse all *.rhtml files in the app/views directory. If users want to validate only one file, they can use $ rake test_templates FILE="path/to/the/file". If $FILE is a directory, it will search for all *.rhtml files in it and try to validate them. If $FILE is a regular file, it will be validated. If $FILE does not exist, RailsTidy will try ".rhtml" appended to $FILE, the app/view directory prepended to $FILE, and the app/view directory prepended and ".rhtml" appended to $FILE.
To validate html output, RailsTidy adds a new assert_tidy method to the Test::Unit::TestCase class. Users can call it with no arguments to validate the last response returned by a test. For example: get :index, assert_success, assert_tidy.
Finally, the plugin allows users to clean the html produced by rails. To enable this feature, an after filter must be used in the app/controller/application.rb file. Note that enabling the filter may cause a significant performance impact. It is not recommended to use this feature unless absolutely necessary.
Version 0.1: N/A