decaporg / decaporg/decap-cms

Differentiate built-in config template variables from fields

Open
#3,100 1 comment 1 reaction 0 assignees View on GitHub
area: configuration kind: enhancement
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Related to #3055 - provides a way to implement that feature without any breaking changes.

**Is your feature request related to a problem? Please describe.**

String templates in the config, such as the slug field, accept field names as variables, but also some built in values like "slug" and "year" ([docs](https://www.netlifycms.org/docs/configuration-options/#slug)). When field names collide with these built in values, you can prefix the variable with "field." to access the field. This is a bit unintuitive.

**Describe the solution you'd like**

Add a prefix to all built in variables. The default could be underscore. Accessing these values would then look like:

```
slug: "{{slug}}{{_slug}}"
```

The above example would provide a slug consisting of a field named "slug" followed by the default slug value. The advantage here is that everything always works one way, versus having to be aware when your field names collide with a built in value, especially as the list of built in values expands. Without this change, every new built in value addition presents a breaking change since fields with the newly used name may already be in use in a CMS instance.

**Describe alternatives you've considered**

Leaving it as is.

**Proposed approach**
- For now, just make the prefixed variants of built in variables available, without any breaking changes.
- Make the prefix configurable, in case the underscore collides with a project's naming scheme.
- Deprecate and warn when a built in variable is accessed without the prefix.
- Next major release we remove access to built in variables without the prefix.

Contributor guide

Open the contributing guide

Research direction

No source files, tests, or entry points are named in the issue, so first locate the config string-template handling and its existing built-in variable resolution. Done means prefixed built-ins are available without breaking current access, the prefix is configurable, and unprefixed built-ins produce deprecation warnings before a later removal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.