Documentation

Templates

url #

Type: Boolean, String

Default: false

This option sets the path to the directory where the templates are stored as html files.

ArticleEditor('#entry', {
    templates: {
        url: '/my-templates/',
        items: {
            mytemplate: "My Template",
            mytemplate2: "My Template 2"
        }
    }
});

In this example, the editor will access the GET request for files in the directory / my-templates / creating the address by the name of the template, like this:

/my-templates/mytemplate.html

The template file can contain any html code.

json #

Type: Boolean

Default: false

This setting allows you to get templates from JSON file.

ArticleEditor('#entry', {
    snippets: {
        url: '/my-templates/templates',
        json: true,
        items: {
            mytemplate: "My Template",
            mytemplate2: "My Template 2"
        }
    }
});

Example of JSON:

{
    "mytemplate": {
        "html": "<p>Hi everyone! This is my template</p>"
    },
    "mytemplate2": {
        "html": "<p>Hi everyone! This is my the other template</p>"
    }
}

Or you can set the JSON object directly to the setting like this:

ArticleEditor('#entry', {
    snippets: {
        json: {
            "mytemplate": {
                "html": "<p>Hi everyone! This is my template</p>"
            },
            "mytemplate2": {
                "html": "<p>Hi everyone! This is my the other template</p>"
            }
        },
        items: {
            mytemplate: "My Template",
            mytemplate2: "My Template 2"
        }
    }
});