![]() |
Summary | Discourse Templates allows the creation of content templates for repeated use. The templates are stored as topics in a special category, where they can be edited and discussed as needed. |
![]() |
Repository Link | https://github.com/discourse/discourse-templates |
![]() |
Install Guide | How to install plugins in Discourse |
This plugin is pretty much a new version of Discourse Canned Replies but it is more flexible and stores the templates in a different way.
Features
This plugin uses a category to store the templates for later use. The first post on each topic of the category will be used as the template for the replies.
This approach provides a lot more functionality then it was available before with discourse-canned-replies
as each template will have edit history, can have associated tags, and the subsequent posts can be used to discuss the content of the template if needed.
Only visible topics will be used as templates, so topics unlisted and archived wonāt be listed.
The plugin also leverages the category security settings to check which users can use the templates. If the user can read the topics in the category then the option to āinsert templatesā in the composer will be available to use.
As the user will only be able to see the templates/topics in the categories that they have access, sub-categories can be used to provide different sets of templates to be used to different groups of users.
How to use it
After installing the plugin, you will need to create a category to store the templates.
Notice that every user that has access to read the topics in this category will be able to use the plugin functionality in the composer.
Pro-tip: The same settings to edit topics will be applied to ātemplateā topics. If you want that anyone with write access in the category be able to edit the existing templates, you should activate
Make new topics wikis by default
on the category settings.
After that, specify the category in the plugin settings.
Thatās it. Now you only have to create some topics in the specified category and they will be available to use as templates.
If you want you can create sub-categories to better organize the templates or to provide different sets of replies to multiple groups of users.
To insert templates you must first open the reply composer and click the extras button, then select the option āInsert templateā
Select the desired template, you can search by text or tags and click on the āpasteā icon.
Pre-filled variables
The plugin supports the following variables on the templates:
my_username
my_name
topic_title
topic_url
original_poster_username
original_poster_name
reply_to_username
reply_to_name
last_poster_username
-
reply_to_or_last_poster_username
.
All the above variables supports fallback text and will strip out the variable if fallback is not specified and the variable canāt be replaced.
Both title and body supports variable replacement.
Example:
Hi %{reply_to_username,fallback:there},
...
Regards,
%{my_name}
If the reply_to_username
is not available, the template will be:
Hi there,
...
Regards,
Arpit Jalan
Migration from discourse-canned-replies
There is a rake task to migrate the existing canned replies to templates:
rake "discourse-templates:migrate-from-canned-replies"
This took only a few seconds to to run on Meta to migrate 47 canned replies so it should be safe to use unless you have a staggering amount of canned replies.
Configuration
The plugin has only two settings:
-
discourse templates enabled
: Activates the plugin -
discourse templates category
: Specifies which category stores the templates.
TODO
- extend functionality to other places beyond the composer
- allow using more than one parent category as template sources