Adds toolbar and addbar buttons for inserting template variables as plain text wrapped in configurable delimiters (default [% Name %]).
Click Variable in the toolbar or addbar and pick a variable name. The wrapped text is inserted at the caret.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/variable/variable.js"></script>
const app = Redactor('#entry', {
plugins: ['variable']
});
string[])
['Name', 'Lastname', 'Email']items is falsy.string)
'[% 'string)
' %]'boolean)
falsetrue, adds the button to the context toolbar as well.string)
Redactor('#entry', {
plugins: ['variable'],
variable: {
items: ['First name', 'Email', 'Order ID'],
start: '{{ ',
end: ' }}'
}
});
en: {
variable: {
title: 'Variable'
}
}
This plugin does not emit events.
Inserts a wrapped variable at the caret and closes the dropdown.
Parameters:
variable (string) — variable name from items.app.variable.add({ variable: 'Email' });