tera icon indicating copy to clipboard operation
tera copied to clipboard

Feature request, `strip_prefix`, and `strip_suffix`

Open EvanCarroll opened this issue 10 months ago • 1 comments

Already internally tera makes use of path.strip_prefix. I would argue .strip_prefix is pretty useful for a templating language. It would be great to have that allowed.

My use case specifically is git cliff which uses tera. I want to strip out the project from the version in a string of project-version. Currently they're combined and I'm trying to work around https://github.com/orhun/git-cliff/issues/1068

EvanCarroll avatar Mar 01 '25 02:03 EvanCarroll

I found the way to do what I want. Since .trim_start_matches only takes a string not a pattern. I could do

 {{ version | split(pat="-") | last }}

EvanCarroll avatar Mar 01 '25 02:03 EvanCarroll