-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves README with real information about how to use this tool.
- Loading branch information
1 parent
54fe136
commit cbf8b8a
Showing
2 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
# Templ | ||
A tool to render templates, and download and update repositories of templates. | ||
A tool to render go text templates. The sweetness is that you can store your text templates in a git repository, | ||
and use templ to download and use that repository of templates. | ||
|
||
Update templates with your text editor, commit to git with your usual workflow, then `templ -u` to download the updates. | ||
|
||
Want to check that your templates are written and parsed correctly before committing them to git? Awesome, templ can be | ||
piped into: | ||
|
||
cat foo.tmpl | templ VAR=VALUE | ||
|
||
![logo](.github/images/templ-logo-smaller.png) | ||
|
||
# Environment variables | ||
TEMPL_DIR - Defaults to ~/.config/templ. Directory that stores template git repositories. You run lists against this dir. | ||
|
||
# Uses | ||
`templ -fetch https://github.com/PlayTechniuque/templ-templates.git` - download a github repository to your templates directory | ||
## Retrieve Templates Stored in a Git Repository | ||
`templ -f https://github.com/PlayTechniuque/templ-templates.git` - download a github repository to your templates directory. | ||
You can set the templates directory with an environment variable TEMPL_DIR or use the default (currently ~/.config/templ) | ||
|
||
`templ -list` - list all available templates | ||
## List your templates | ||
`templ -l` - list all downloaded templates | ||
`templ templatename` - display the contents of a template file to stdout. It's like cat, but it has partial file matching, | ||
so if you have a template file in a directory structure `foo/bar/bam.yaml` then you can use `templ foo` or `templ bam.yaml` | ||
or `templ bar/bam`. | ||
|
||
`templ templatename` - display the contents of a template file to stdout. | ||
If you have two files `foo/bar/bam.yaml` and `zee/zye/bam.yaml`, then `templ bam` will show both of the `bam.yaml` files. | ||
|
||
`templ templatename=variablesfile.yaml` - hydrate a template file using variablesfile.yaml. | ||
## Rendering templates | ||
You have two options for rendering templates. The first and simplest is to put the template file on | ||
stdout and then pipe that template through templ itself, replacing variables with values: | ||
`templ templatename | templ KEY=VALUE` - pipeline a render operation! You do not need a config file, you can pipe through | ||
templ itself. This is best suited for replacing simple variables, not using template logic | ||
|
||
`templ templatename=variablesfile.yaml` - hydrate a template file using variablesfile.yaml. This gives you more | ||
flexibility in composing more complex templates. | ||
|
||
```variablesfile.yaml | ||
--- | ||
Variable: value | ||
OtherVariable: othervalue | ||
``` | ||
|
||
`templ templatename | templ KEY=VALUE` - pipeline a render operation! You do not need a config file, you can pipe through templ itself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters