Skip to content

Releases: jeremybower/tmpl

v2.0.2

23 Aug 17:16
v2.0.2
bb76b66
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.0.1...v2.0.2

v2.0.1

21 Aug 19:48
v2.0.1
a0064d6
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v2.0.0...v2.0.1

v2.0.0

22 Jul 19:11
v2.0.0
4a3dd7a
Compare
Choose a tag to compare

Overview

File Mounts

The v2 version changes the way template files (and other files) are consumed by tmpl. In the previous major version, only templates were given to tmpl as arguments, which had the significant limitation that only templates could be referenced by other templates.

In v2, there are flags to mount files and directories to specific paths for tmpl to access. For example, now tmpl can use the presence of other files to change the generated text (even if those files aren't included in the generated text) without passing them as templates.

  • Continue to use include to dynamically include templates, but the first parameter is now the mounted path to the file.
  • Use the new files and dirs built-in functions to list mounted files and directories that match the given glob pattern.
  • Use the new filename built-in function to get the mounted filename of the currently executing template.

File mounts also enable including files by relative paths. Previously, a template could only include another templates by using an absolute path.

Include Text Files

In addition to dynamically including other templates, v2 can dynamically include other text files without treating them as templates through the includeText built-in function. This means that large blocks of text can be separated from the template itself for easier maintainability.

Missing Keys

The default behaviour of Go templates is to quietly replace missing keys with "". Version 2 changes that behaviour to return an error when a missing key is referenced. Failing loudly is usually preferable, but there might be reasons to instead render "" or the zero value. The default behaviour can be changed by using the --missingkey flag. Since it is made redundant by this feature, the require function has been removed in v2.

What's Changed

Full Changelog: v1.1.0...v2.0.0

v1.1.0

18 Jul 20:13
v1.1.0
cfbbc9a
Compare
Choose a tag to compare
  • Adds license to CLI

v1.0.0

17 Jul 20:46
6cab082
Compare
Choose a tag to compare
v1.0.0