Template Service

If you wish to provide your own custom templates you can use the templateServiceUrl startup parameter. This parameter defines a base url for a REST based service that conforms to the specifications described in this document. You will have to create this REST service using the server side technology of your choice. Please refer to the documentation provided by your server side technology on how to accomplish this.

Keep in mind that if you do not wish to provide custom templates simply omit the templateServiceUrl parameter from the startup method and the default set of template groups will be provided by the server.

Template REST Requests

There are four REST end points you are required to implement.

  1. Get a list of template groups
  2. Get information about an individual group
  3. Get information about an individual group filtered by search query
  4. Get template by ID.

Example

editor = new ESDWeb(null, 'editorNode');

/* set other properties here */

editor.startup({
    /* other parameters */,
    templateServiceUrl: "http://www.example.com/REST"
});
		

REST End Points

You are required to implement the following REST end points. Each will return a JSON string in the specified format.

Get Groups

Returns a list of all template groups.

<template service URL>/groups

The result will be a JSON string in the following format:

[
    "group name one",
    "group name two,
    ...
]
		

Get Group Info

Returns info on all the templates in the group with name <group name>

<group name> is a parameter that will be one of the strings returned by the call to "Get Groups".

<template service URL>/group/<group name>

The result will be a JSON string in the following format:

[
    {
        "id": <template ID>,
        "name": "<template name>",
        "description": "<template description>"
    },
    ...
]
		

Get Group Info by Search Query

Returns info on templates in the group with name <group name> that match the query <query>.

<template service URL>/group/<group name>?s=<query>

The result will be a JSON string in the following format:

[
    {
        "id": <template ID>,
        "name": "<template name>",
        "description": "<template description>"
    },
    ...
]
		

Get Template by ID

Returns the SVG of the template with <template id> as a string.

<template service URL>/template/<template id>

Server MIME Types

You may need to configure a MIME type to deliver the template library JSON:

  • .json - application/json

For information on MIME type configuration please refer to the documentation for your web server.