Variable

Click on the variable button in the toolbar, then choose a variable from the popup to insert it.

Code

<!DOCTYPE html>
<html>
    <head>
        <title>Redactor</title>
        <meta charset="utf-8">

        <!-- css -->
        <link rel="stylesheet" href="/your-folder/redactor.css" />
    </head>
    <body>
        <!-- element -->
        <textarea id="entry">...</textarea>

        <!-- js -->
        <script src="/your-folder/redactor.js"></script>
        <script src="/your-folder/plugins/variable/variable.js"></script>

        <!-- call -->
        <script>
        Redactor('#entry', {
            plugins: ['variable'],
            variable: {
                items: ['Name', 'Lastname', 'Company', 'Email'],
                start: '{% ',
                end: ' %}'
            }
        });
        </script>
    </body>
</html>

Usage

Here are the possible settings for the plugin. Set the variables that will be in the dropdown menu with items and the start and end of the template with start and end:


Redactor('#entry', {
    plugins: ['variable'],
    variable: {
        items: ['Name', 'Lastname', 'Company', 'Email'],
        start: '{% ',
        end: ' %}'
    }
});

By default, start and end have this values:


start: '[%',
end: '%]'

By default, the plugin only adds its button to the toolbar. To add it to the context bar, enable the context setting:


Redactor('#entry', {
    plugins: ['variable'],
    variable: {
        context: true,
        items: ['Name', 'Lastname', 'Company', 'Email']
    }
});