Skip to content

[#470] add map helper to the templating system#471

Merged
klappradla merged 8 commits into
bitcrowd:mainfrom
ilyabayel:feature/470-add-conditional-formatting-logic-to-customize-branch-commit-prefixes
Feb 16, 2026
Merged

[#470] add map helper to the templating system#471
klappradla merged 8 commits into
bitcrowd:mainfrom
ilyabayel:feature/470-add-conditional-formatting-logic-to-customize-branch-commit-prefixes

Conversation

@ilyabayel

@ilyabayel ilyabayel commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Hey, folks! How is it going?
Could you please review this MR and check if it useful to have this feature?

Add map helper function to templating system for conditional mapping strings

Closes: #470

@ilyabayel ilyabayel changed the title feat: add map helper to the templating system [#470] add map helper to the templating system Feb 10, 2026

@klappradla klappradla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ilyabayel 👋

welcome and thanks for your contribution 🙏

I think it's a viable use case and a feature that others could also benefit from. So yes, let's do this.

I have some thought on the implementation details though. May be personal preference, but I find the "array"-style format for something that's supposed to be a key-value-mapping a bit irritating and hard to read. How about we encode key and value as a string instead, like so:

{type | map("story:feat", "bug:fix", "task:chore")}

I would prefer to only have one syntax. This ☝️ is a bit the middle of what you proposed. What do you think?

Comment thread src/core/format/helpers.ts
Comment thread src/core/format/helpers.ts Outdated
export const lowercase = (): StringMappingFn => (s) => s.toLowerCase();

// This is a mapping function, it can be used in two ways:
// 1. With an object: map({ a: "b" }) will return a function that maps "a" to "b" and returns the original value for any other input.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try this out in the settings? It does not work for me and I think™ that's because the { and } are reserved characters in our DIY templating language.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only in unit tests, but not in chorme itself. Probably it's broken there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@ilyabayel

ilyabayel commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Hey @ilyabayel 👋

welcome and thanks for your contribution 🙏

I think it's a viable use case and a feature that others could also benefit from. So yes, let's do this.

I have some thought on the implementation details though. May be personal preference, but I find the "array"-style format for something that's supposed to be a key-value-mapping a bit irritating and hard to read. How about we encode key and value as a string instead, like so:

{type | map("story:feat", "bug:fix", "task:chore")}
I would prefer to only have one syntax. This ☝️ is a bit the middle of what you proposed. What do you think?

Hey @klappradla, thanks for welcoming me!

I initially chose the map("key", "value") syntax for two reasons:

  1. It resembles familiar patterns like SQL's json_build_object('key', value, 'key2', value)
  2. It's simple to implement, support, and use

I like your proposed syntax too, but there's an important edge case to consider:

{url | map("https\://google.com:https\://youtube.com")}

vs

{url | map("https://google.com", "https://youtube.com")}

The second variant is more readable when values contain colons.

So there is a trade-off:

  • The "a:b" syntax works well for simple values
  • The "a", "b" is more robust and requires no escaping

I'm open to either approach - what do you think?

@klappradla

klappradla commented Feb 12, 2026

Copy link
Copy Markdown
Member

I like your proposed syntax too, but there's an important edge case to consider:

{url | map("https\://google.com:https\://youtube.com")}

vs

{url | map("https://google.com", "https://youtube.com")}

The second variant is more readable when values contain colons.

So there is a trade-off:

* The `"a:b"` syntax works well for simple values

* The `"a", "b"` is more robust and requires no escaping

I'm open to either approach - what do you think?

Oh, very good point! Well while I would have preferred the "key:value" syntax, the string array is truely more robust and easier to maintain, you're right. So let's go with that one 👍

@klappradla klappradla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!

I'd suggest a small simplification on the function itself and align the doc string still. For whether mapping should be plural or not, that's probably personal preference. I'm undecided myself 🙈

Comment thread src/core/format/helpers.ts Outdated
Comment thread src/core/format/helpers.ts Outdated
Comment thread src/core/format/helpers.ts
Comment thread src/core/format/helpers.ts Outdated

@klappradla klappradla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates 🙏

Looking good ✨

I'm not sure when I'll come around to release this. But hopefully this week. I'll keep you posted @ilyabayel 💌

@klappradla klappradla merged commit 94f03fa into bitcrowd:main Feb 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add conditional formatting logic to customize branch/commit prefixes

2 participants