Closed bitboxer closed 4 years ago
I will have some time to implement it in 2-3 weeks I think. So if you like it, ping me and I will try to do it.
Ha, interesting. 😁 Can you share which build system this is?
I am not 100% sure if there'll be time for us to work on this before you get around to it. I suggest whoever starts working on it, just drops a comment here. ✌️
To implement this, I think our template syntax needs to be extended. At the moment, the transforms/filters you can apply to template values do not accept/expect arguments.
My idea would be to update template.js to support the following syntax:
{type}/{title | slugify | limit(32)}
…so filters can have (optional) arguments.
Our helpers, instead of directly taking in the value would receive these "configuration" arguments and then return the filter function itself.
export const limit = (maxLength) => (s) => s.substring(0, maxLength);
export const lowercase = () => (s) => s.toLowerCase();
export const shellquote = () => (s) => typeof s === 'string' ? `'${s.replace(/'/g, "'\\''")}'` : "''";
export const slugify = () => createSlug({ separator: '-' });
export const trim = () => (s) => s.replace(/^\s+|\s+$/g, '');
export const uppercase = () => (s) => s.toUpperCase();
Thanks for proposing this. 💚
Its using aws amplify to generate branch previews and somehow the dns has a length limit and those branch names as subdomain make it explode 🤣 .
Also yes, I will extend the template language like you proposed 😉
@pmeinhardt thanks for implementing this 🥳
I would love to have a helper to limit string lenghts because the branch names are getting waaaay to long sometimes. So long that they break a build system I have to use for a customer right now :trollface: .