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 · 0 comments
Open

"remove" syntax for string transform #20

jake-figma opened this issue Feb 3, 2024 · 0 comments
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
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

1 participant