README.md in shortcode-0.1.1 vs README.md in shortcode-0.1.2

- old
+ new

@@ -1,7 +1,9 @@ # Shortcode +[![Build Status](https://travis-ci.org/kernow/shortcode.png?branch=master)](https://travis-ci.org/kernow/shortcode) + A ruby gem for parsing Wordpress style shortcodes. The gem uses a [PEG](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (Parsing Expression Grammar) parser rather than using regular expressions so its easier to understand, test and extend. ## Installation Add this line to your application's Gemfile: @@ -97,11 +99,11 @@ Sometimes the data passed to the template from the shortcode it not enough. Lets say you want to render a gallery of images using id numbers of images stored in a database, e.g. `[gallery ids="1,2,3,4"]`. This is where presenters can help, they allow you to modify the `@content` and `@attributes` variables before they are sent to the template for rendering. Presenters are simple classes that define four methods. The class method `for` should return the name of the shortcode (as a symbol) it should be applied to. The classes `initialize` method received the `attributes` and `content` variables. Finally the class should define `content` and `attributes` methods. In a rails app you could return image records to the template using something like this: ```ruby -class CustomPrsenter +class CustomPresenter def self.for :quote end @@ -119,20 +121,20 @@ end private def images - @attributes.ids.split(',').collect { |n| Image.find(n) } + Image.where("id IN (?)", @attributes[:ids]) end end ``` #### Registering presenters To register a presenter simply call `Shortcode.register_presenter` passing the presenter class e.g. ```ruby -Shortcode.register_presenter(CustomPrsenter) +Shortcode.register_presenter(CustomPresenter) ``` ## Contributing 1. Fork it