-
Notifications
You must be signed in to change notification settings - Fork 0
Generate a Custom Renderer
rzig edited this page Feb 25, 2017
·
3 revisions
With Redcarpet, you can roll your own renderer. To simplify managing custom renderers in your Rails app, Carpet provides a generator for you to use.
Excecute:
rails g carpet your_renderer_name
This will generate a file at app/redcarpet_renderers/your_renderer_name.rb
. This will be a simple file with a single class called YourRendererName
. The class name in this file should not be changed - it needs to be the camel case version of the file name. Once you've generated the file, add rendering methods as described in the Redcarpet Docs. To use this renderer for a field in your model, see this example.