-
Notifications
You must be signed in to change notification settings - Fork 0
Generate a Custom Renderer
railsrocks edited this page Mar 29, 2016
·
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
. In this file, there will be a simple class for you to put your rendering methods. The class name in this file should not be changed - it needs to be the camel case version of the file name. To use this renderer for a field in your model, see this example.