Tom Payne

Results 193 comments of Tom Payne

Note to self: some template functions are not threadsafe, for example `glob` temporarily changes the working directory of the process. As `modify_` scripts can be templates, care will be need...

> That seems odd, surely it would be sense to be able to execute a glob relative any directory, not just the current working directory? The `glob` template function is...

chezmoi copies `modify_` scripts to a file in a temporary directory, sets the executable bit on the file, and then executes them. This is needed even if the `modify_` script...

> Perhaps we could also take the opportunity to implement a higher-order function The tricky thing here is that `text/template` is, by design, a simple language and does not support...

Ah, sorry I misunderstood. My misunderstanding was that I thought that `each` was to be a **template function** that took a function and a list as arguments and returned a...

Note it's also possible to extend template functions so that they operate on lists as well as isolated values. For example, we can extend `quote` to return a list of...

So, sadly, thanks to Masterminds/sprig's inherent brokenness, this isn't as immediately fixable as I had hoped. Some specific problems: * Masterminds/sprig's `quote` function already accepts lists ... and quotes them:...

https://github.com/chezmoi/templatefuncs contains some initial replacement template functions. It's a work in progress.

I [asked on golang-nuts](https://groups.google.com/g/golang-nuts/c/A5qsATqlv_U) if there are existing alternatives to Minorminds/sprig.

So, I propose to make this change in an incremental way, without needing chezmoi v3, with the following strategy: 1. Add a `template.functions` config variable which is a list of...