# Template

> Editor42 Template plugin: insert predefined HTML templates from an array, a JSON URL or a callback, with placeholders for dates and the selected content.

Source: https://editor42.com/plugins/template  
Every page of editor42.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://editor42.com/llms-full.txt

Plugin alias: `template`

```js
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

| Option | Type | Default | Description |
|---|---|---|---|
| `template_cdate_classes` | string | `cdate` | CSS classes for creation date elements. |
| `template_mdate_classes` | string | `mdate` | CSS classes for modification date elements. |
| `template_selected_content_classes` | string | `selcontent` | CSS classes for selected-content placeholders. |
| `template_preview_replace_values` | object | — | Key-value map for preview substitutions. |
| `template_replace_values` | object | — | Key-value map for insertion substitutions. |
| `templates` | string/object[]/function | `[]` | Template source. |
| `template_cdate_format` | string | `%Y-%m-%d` | Creation date format. |
| `template_mdate_format` | string | `%Y-%m-%d` | Modification date format. |

## Commands

| Command | Description |
|---|---|
| `editor42InsertTemplate` | Inserts template HTML with variable substitution. |
| `editor42Template` | Opens template selection dialog. |

## Toolbar buttons

| Button | Type | Description |
|---|---|---|
| `template` | Button | Opens template selection dialog. |

## Menu items

| Item | Description |
|---|---|
| `template` | Opens template selection dialog. |
