Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switching README to use markdown.

  • Loading branch information...
commit 733ceab4e5d9bccdfacb92bf5a24b43ffd591dcf 1 parent e9a3150
@techiferous authored
Showing with 17 additions and 14 deletions.
  1. +17 −14 README.rdoc → README.md
View
31 README.rdoc → README.md
@@ -1,25 +1,25 @@
-= Rack::Plastic
+# Rack::Plastic
-== Description
+## Description
If you are creating Rack middleware that changes the HTML response, use
Rack::Plastic to get a head start. Rack::Plastic takes care of the
boilerplate Rack glue so that you can focus on simply changing the HTML.
-== Usage
+## Usage
There are two ways you can change the HTML: as a Nokogiri document or as
a string. Simply define one of the following methods:
- def change_nokogiri_doc(doc)
- ... insert code that changes the doc ...
- doc
- end
+ def change_nokogiri_doc(doc)
+ ... insert code that changes the doc ...
+ doc
+ end
- def change_html_string(html)
- ... insert code that changes the html string ...
- html
- end
+ def change_html_string(html)
+ ... insert code that changes the html string ...
+ html
+ end
If you define both methods, change_nokogiri_doc will be called first, then
the doc will be converted to an HTML string, then the string will be
@@ -28,18 +28,18 @@ passed to change_html_string.
Rack::Plastic also provides some convenience methods for interacting with
Rack and Nokogiri as well as some convenience methods for testing.
-== Examples
+## Examples
The examples/middlewares directory has examples of writing middleware using
Rack::Plastic.
-== Rails Streaming
+## Rails Streaming
This middleware is not compatible with Rails HTTP streaming. According to [Railscast #266](http://asciicasts.com/episodes/266-http-streaming):
"Also, streaming is incompatible with some middleware. If the middleware modifies the response
then it will not work with streaming."
-== Testing
+## Testing
Rack::Plastic comes with some test helpers that make it easier for you to
write tests for your Rack middleware. Refer to the documentation for
@@ -50,16 +50,19 @@ but it provides manual tests. Each of the example middlewares is inserted into
Sinatra, Rails, and Rack test app.
To run the Rails test app:
+
* cd examples/railsapp
* script/server
* point your browser to http://localhost:3000
To run the Sinatra test app:
+
* cd examples/sinatraapp
* ruby app.rb
* point your browser to http://localhost:4567
To run the Rack test app:
+
* cd examples/rackapp
* rackup config.ru
* point your browser to http://localhost:9292
Please sign in to comment.
Something went wrong with that request. Please try again.