Skip to main content

Template

Plugin alias: template

editor42.init({
plugins: 'template'
});

Allows inserting predefined HTML templates into the editor. Templates can be specified as an inline array, a URL to a JSON endpoint, or a callback function. Supports special placeholder classes for creation date, modification date, and selected content replacement, plus {$variable} substitution syntax.

Options

OptionTypeDefaultDescription
template_cdate_classesstring'cdate'CSS classes for creation date elements.
template_mdate_classesstring'mdate'CSS classes for modification date elements.
template_selected_content_classesstring'selcontent'CSS classes for selected-content placeholders.
template_preview_replace_valuesobjectKey-value map for preview substitutions.
template_replace_valuesobjectKey-value map for insertion substitutions.
templatesstring/object[]/function[]Template source.
template_cdate_formatstring'%Y-%m-%d'Creation date format.
template_mdate_formatstring'%Y-%m-%d'Modification date format.

Commands

CommandDescription
editor42InsertTemplateInserts template HTML with variable substitution.
editor42TemplateOpens template selection dialog.

Toolbar buttons

ButtonTypeDescription
templateButtonOpens template selection dialog.
ItemDescription
templateOpens template selection dialog.