1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 00:45:38 +00:00

add ability to have more methods available from within the templates

This commit is contained in:
deadc0de6
2018-11-19 18:16:35 +01:00
parent 0f88bf8b1c
commit d569201b0b
4 changed files with 139 additions and 2 deletions

View File

@@ -84,6 +84,7 @@ why [dotdrop](https://github.com/deadc0de6/dotdrop) rocks.
* [Templating](#templating)
* [Available variables](#available-variables)
* [Available methods](#available-methods)
* [Dotdrop header](#dotdrop-header)
* [Example](#example)
@@ -781,6 +782,22 @@ alias dotdrop='eval $(grep -v "^#" ~/dotfiles/.env) /usr/bin/dotdrop --cfg=~/dot
The above aliases load all the variables from `~/dotfiles/.env`
(while omitting lines starting with `#`) before calling dotdrop.
## Available methods
Beside jinja2 global functions
(see [jinja2 global functions](http://jinja.pocoo.org/docs/2.10/templates/#list-of-global-functions)
the following functions are available and can be used within the templates:
* `exists(path)`: return true when path exists
```
{%@@ if exists('/dev/null') @@%}
it does exist
{%@@ endif @@%}
```
If you'd like a specific function to be available, either open an issue
or do a PR.
## Dotdrop header
Dotdrop is able to insert a header in the generated dotfiles. This allows