☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

commit_templates[*]

Table of contents

Description:

This key represents an individual commit template object in the commit_templates array.

The value is an object that defines a template for commit messages when saving changes. Each template object can contain optional label, template_path, template_string, wrap_width, extra_data, and _inputs keys.

Appears in:
└── commit_templates
    └── [*]
Type:
Object
Properties:

This key defines additional template strings for building nested templates.

The value is an object that can contain any properties. Each property value can be any data type and specifies additional data to include in commit message templates.

Show examplesHide examples

In this example, we have configured a commit template with extra data to include a breaking change message.

Copied to clipboard
commit_templates:
  - label: Breaking change
    template_string: '{message}{breaking_change|if=breaking_change_message}'
    _inputs:
      breaking_change_message:
        type: text
    extra_data:
      breaking_change: ⚠️ {breaking_change_message}
{
  "commit_templates": [
    {
      "label": "Breaking change",
      "template_string": "{message}{breaking_change|if=breaking_change_message}",
      "_inputs": {
        "breaking_change_message": {
          "type": "text"
        }
      },
      "extra_data": {
        "breaking_change": "⚠️ {breaking_change_message}"
      }
    }
  ]
}

This key defines which inputs are available at a given level of the configuration cascade.

This key has no default.

If undefined at higher levels of the configuration cascade, _inputs will default to any values configured in the CloudCannon configuration file.

Show examplesHide examples

In this example, we have configured the date_created key as a Date and Time Input, which will automatically populate when you create a file using this input. Editors cannot alter this input as the interface is disabled.

Copied to clipboard
_inputs:
  date_created:
    type: datetime
    label: Date of article creation
    comment: UTC +0 timezone
    context:
      open: false
      title: Help
      icon: help
      content: This date field will automatically populate when you create an article.
    hidden: false
    disabled: true
    instance_value: NOW
    cascade: true
    options:
      timezone: Etc/UTC
{
  "_inputs": {
    "date_created": {
      "type": "datetime",
      "label": "Date of article creation",
      "comment": "UTC +0 timezone",
      "context": {
        "open": false,
        "title": "Help",
        "icon": "help",
        "content": "This date field will automatically populate when you create an article."
      },
      "hidden": false,
      "disabled": true,
      "instance_value": "NOW",
      "cascade": true,
      "options": {
        "timezone": "Etc/UTC"
      }
    }
  }
}

In this example, we have configured the blog_tags key as a Multiselect Input in the blog Collection.

Copied to clipboard
collections_config:
  blog:
    _inputs:
      blog_tags:
        type: multiselect
        label: Blog type
        comment: Select a blog type
        context:
          open: false
          title: Help
          icon: help
          content: |
            Blog tags help our users filter articles by topic.
        options:
          values:
            - Opinion
            - Feature
            - Resource
{
  "collections_config": {
    "blog": {
      "_inputs": {
        "blog_tags": {
          "type": "multiselect",
          "label": "Blog type",
          "comment": "Select a blog type",
          "context": {
            "open": false,
            "title": "Help",
            "icon": "help",
            "content": "Blog tags help our users filter articles by topic.\n"
          },
          "options": {
            "values": [
              "Opinion",
              "Feature",
              "Resource"
            ]
          }
        }
      }
    }
  }
}
labelstring#

This key defines the name of a commit template, which appears in the dropdown menu when saving changes.

The value is a string that specifies the label text for the template.

Show examplesHide examples

In this example, we have configured a commit template with the label "Default".

Copied to clipboard
commit_templates:
  - label: Default
    template_string: '{commit_type}: {message|trim}'
{
  "commit_templates": [
    {
      "label": "Default",
      "template_string": "{commit_type}: {message|trim}"
    }
  ]
}

This key defines the path to a file containing your commit template.

The value is a string that specifies a file path relative to the root directory. CloudCannon will use the contents of this file as the commit template.

CloudCannon will not use this file if template_string is also defined for the commit template.

Show examplesHide examples

In this example, we have configured a commit template to use a file at /.git/commit-message.txt.

Copied to clipboard
commit_templates:
  - label: Commit message from file
    template_path: /.git/commit-message.txt
{
  "commit_templates": [
    {
      "label": "Commit message from file",
      "template_path": "/.git/commit-message.txt"
    }
  ]
}

This key defines the template string for the commit message.

The value is a string that specifies the commit message template. This template can include template variables and filters.

CloudCannon will only use this template string if template_path is not set for the commit template.

Show examplesHide examples

In this example, we have configured a commit template with a template string that includes template variables.

Copied to clipboard
commit_templates:
  - label: Default
    template_string: '{commit_type}: {message|trim}'
    _inputs:
      commit_type:
        type: select
        options:
          values:
            - feature
            - fix
{
  "commit_templates": [
    {
      "label": "Default",
      "template_string": "{commit_type}: {message|trim}",
      "_inputs": {
        "commit_type": {
          "type": "select",
          "options": {
            "values": [
              "feature",
              "fix"
            ]
          }
        }
      }
    }
  ]
}

This key defines the width of the text wrap in the commit message editor.

The value is a number that specifies the character width at which text wraps in the editor.

Show examplesHide examples

In this example, we have configured a commit template with a wrap width of 72 characters.

Copied to clipboard
commit_templates:
  - label: Default
    template_string: '{message}'
    wrap_width: 72
{
  "commit_templates": [
    {
      "label": "Default",
      "template_string": "{message}",
      "wrap_width": 72
    }
  ]
}
Examples:

In this example, we have configured a commit template with a template string and input configuration.

Copied to clipboard
commit_templates:
  - label: Default
    template_string: '{commit_type}: {message|trim}'
    _inputs:
      commit_type:
        type: select
        options:
          allow_empty: true
          values:
            - feature
            - fix
            - test
        cascade: true
{
  "commit_templates": [
    {
      "label": "Default",
      "template_string": "{commit_type}: {message|trim}",
      "_inputs": {
        "commit_type": {
          "type": "select",
          "options": {
            "allow_empty": true,
            "values": [
              "feature",
              "fix",
              "test"
            ]
          },
          "cascade": true
        }
      }
    }
  ]
}
Open in a new tab