Clone this wiki locally
What is a component?
A component is a reusable element that can be used when building evaluations' templates. A few sample components, including templates to render tweets, Twitter users, and searches on Twitter are included in Clockwork Raven, but it's easy to add your own.
Who can add components?
You must have access to the server running Clockwork Raven to add templates, and you must be able to restart Clockwork Raven. We plan to add support for user-created templates that can be added via the Clockwork Raven web interface in the future.
How do I add a component?
There are three steps to creating a component.
Step 1: Creating the HTML template
Create a template for the HTML. Out of the box, ERb and HAML are supported, but you can add other templating engines to your Gemfile and then use those if you like. Put your template in
app/views/components/ and call it
_<name>.html.haml for a HAML template or
_<name>.html.erb for an ERb template (note that
<name> is whatever you want to call your template).
Your component will be able to take parameters from the user when the user uses it an a template. You can access these parameters with
Here's a sample ERb template:
Step 2: registering with the manifest
Add an entry to the manifest file,
app/views/components/manifest.yml, for your template. It's pretty easy to see the format from that file. You create an entry with the same name as your template file (but without the leading
_ or the trailing
.html.erb. The name should be a symbol (start with
:). That entry has a
:desc entry with a friendly description of your component. It also has a
:vars entry which lists the parameters your component expects. Each entry in
:vars has a description (
:desc) and a boolean (
:required) to indicate whether the parameter is required. Here's what the manifest entry would look like for the above component:
:my_comp: :desc: My Awesome Component :vars: :param1: :desc: First parameter :required: true :param2: :desc: Second parameter :required: false
Step 3: Restart the server
You'll need to restart your server and your Resque workers to pick up the new component.
Made an awesome component?
Made a really awesome component? Submit a pull request or send us an email and we'll see about including it in Clockwork Raven if we think it'll be useful to many users.