Templates

File templates are available via the File / New From Template menu and are a way to create files with content that serves as a base for a new file of a certain type or for a certain purpose. This article describes how to create a custom theme and add it to a Cloud9 Bundle.

1470

Creating a Template File

A template file is a collection of multiple templates. The basic format is similar to the one used for snippets.

Templates start with a list of variable definitions and then a list of lines that contain the code of the template itself.

# Comment
<field> <value>
<field> <value>
<tab>templatecontents
<tab>templatecontents
template ended

A file can contain any number of these underneath each other.

Creating a Template

There are three required fields that must be present for each template.

  • filename The filename for the file. Specify only the extension.
  • caption The caption of the menu item for this template.
  • section The grouping of the template. This may have / as a separator of levels.

Example

The example below contains two snippets. One for an xml and for an html document.

filename .html
section General
caption HTML file
	<!DOCTYPE html>
	<html>
	    <head>
	        <title> </title>
	    </head>
	    <body>
	
	    </body>
	</html>
filename .xml
section General
caption XML file
	<?xml version="1.0" encoding="UTF-8"?>
	<root />

Adding Templates to a Bundle

A bundle can contain one or more template files. Each template file must be placed in the templates directory and have the extension .templates.

Suppose your template file is called node.templates. Your file structure will look something like this:

└─ your.plugin
    ├─ templates
    |    └─ node.templates
    ├─ package.json
    └─ README.md