Closed Arteneko closed 4 years ago
|
is not allowed on Windows filenames so the second proposal is not a good solution. We could replace the |
by something else for the filenames only but that would be a weird gotcha maybe?
I need to think a bit about the first one.
Maybe 1.0 is premature if there are more feature request on the schema, I'll release a <1 version in the meantime and we can discuss improvements.
I'm kind of warming up to allowing both |
and something else like $$
if you want it to work on Windows for filenames/directories only.
I guess a "less-common" but more compatible option, such as $$
(if compatible with every supported OS) would be better than to allow both, it provides less confusion around what to use, and will allow for maximum compatibility, as to follow the tool's base goal.
The issue is that |
is the official token for filters in Tera so unless we strip them somehow they would be supported, even if not officially/mentioned in the docs. All the code handling would do is render(path.replace("$$", "|"))
I think adding $$
(or anything else that works on every OS) as a solution is good in the end. It's pretty niche to need that anyway, cookiecutter still doesn't have it and they do ok.
Are you interested in making a patch for that?
Sure enough, making a fork for that, right now!
I have a template where I request two related info.
This slug is closely related to the name, and I'd like to be able to have something to slugify the name the user entered, and use that resulting value as template value.
This would introduce a change, with a concept of transformations.
I see a few ways this could be done.
transforms
inside thetemplate.toml
fileOne way would be, for a given variable (one
[[variables]]
), to be able to provide a new key, whose format would be expected as a key-value object.The resulting object would look like this.
Template variable usage filter application
The second proposal would be to allow a pipe syntax in the placeholder keys, which would then be ran, and the resulting string would be used.
The algorithm here would be pretty simple.
End
Of course, every method is built-in, and documented.
What do you think?