I want to create a custom filter for auto_html. Where do I put the filter so I can use it? The documentation doesn't touch on any of that. Thanks!
The approach I took was to add the code to an initializer file such as:
/path/to/your/application/config/initializers/auto_html.rb
Then you can just write something like:
AutoHtml.add_filter(:change_colours).with({}) do |text, options|
text.gsub("#FF0000", "#00FF00")
end
And call auto_html(input) { change_colours }
in your model. The empty hash will take any options you care to pass to the filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With