Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"remove" syntax for string transform #20

Open
jake-figma opened this issue Feb 3, 2024 · 1 comment
Open

"remove" syntax for string transform #20

jake-figma opened this issue Feb 3, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jake-figma
Copy link
Collaborator

jake-figma commented Feb 3, 2024

A way to remove a substring from a string. Proposed approach would be a second pipe after the filter. This way, the template explicitly states how the input string should be filtered and transformed prior to searching for the substring. This gives template authors a reliable format to match against (they can always use raw filter if they want the original string):

  • {{something|pascal|Something}} would remove "Something".
    • "SomethingGrand" becomes "Grand"
    • "something wonderful friend" becomes "WonderfulFriend"

Additionally, we could take the regex-y HTML attribute selector syntax from CSS (^ for "starts with" and $ for "ends with") and supplement with:

  • {{something|pascal|^Something}} only a starting instance of "Something"
    • "SomethingGrand"
  • {{something|pascal|$Something}} only an ending instance of "Something"
    • "GrandSomething"
@jake-figma jake-figma added the enhancement New feature or request label Feb 3, 2024
@jake-figma jake-figma self-assigned this Feb 3, 2024
@jake-figma jake-figma changed the title Remove syntax for string transform "remove" syntax for string transform Feb 3, 2024
@mikeysouthwell
Copy link

Hey Jake, any update on this? It would be really good if we could transform the string output for this to remove "px" on the end of numbers and also to help break up long-winded strings, such as those for Shadow into more manageable outputs. Currently Shadow for a red drop shadow as an example is:

“0px, 1px, 2px, 0px rgba(208,10,14,0.10)”

It would be good to be able to access each of these values independently and add a string on front of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants