jch/html-pipeline — pull request #151 by bkeepers (2014-09-30 18:25:40+00:00)
Title: Objects to encapsulate whitelist

This is an experiment with adding real objects to represent the whitelist instead of a deeply nested hash. See [sanitize-whitelist](https://github.com/bkeepers/sanitize-whitelist) for the implementation.

## Advantages

- `#dup` with a block can be called on existing whitelists to create a new whitelist with modifications
- the whitelist is frozen after it is initialized or dup'd.
- `#to_h` converts it to the hash that the `sanitize` gem expects

## Example

```ruby
class MySanitizationFilter < HTML::Pipeline::SanitizationFilter
CUSTOM_WHITELIST = WHITELIST.dup do
remove "object"
allow "time"
element(:all).allow("id")
element("span").allow("class")
end

def whitelist
CUSTOM_WHITELIST
end
end
```

/cc @jch @mastahyeti @ptoomey3 @mislav @josh