Skip to content

[EXTENSIONS] How to register own templates

MotionCode Dev edited this page Jun 29, 2026 · 1 revision

Welcome!

This is a quick guide on how to register your templates (placeholders for empty files) in your extension

Get started

First, you need to add the following key to your package.json:

"templates.register": "templates/config"

Here is the path to your config file. The path is absolute, but in this example, it points to the templates folder inside the extension folder, where the config.json file is located.

Next, let's look at a minimal example of the config file's contents:

{
    "slim": [
        {
            "name": "Hello, World!",
            "content": "log(\"Hello, World!\")\n"
        },
        {
            "name": "Enum",
            "content": "enum Enum {\n\tMember\n\tAdmin\n}"
        },
        {
            "name": "Data structures",
            "content": "struct Structure {\n\tname: string\n\tid: int\n}"
        }
    ]
}

In this example, the template will be available when you open a .slim file (only the last word after the period is taken into account, meaning that a file named index.xxx.slim will also be a .slim file). As you can see, you can use \t and \n for line breaks or tabs, which will work perfectly in the editor.

Let’s break down the fields:

  • name - The template’s name; it will appear in the list
  • content - The content that will be inserted into the editor when clicked

Clone this wiki locally