1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 20:19:46 +00:00
Files
dotdrop/docs/template/template-variables.md
2022-09-03 16:10:13 +02:00

3.4 KiB
Vendored

Template variables

Available variables

The following variables are available in templates:

Enriched variables

The below variables are added to the available variables within templates. If the variable is already set by the user (through the config file for example) it will not be overwritten.

Dotfile variables

When a dotfile is handled by dotdrop, the following variables are also available for templating:

  • {{@@ _dotfile_abs_src @@}} contains the processed dotfile absolute source path.
  • {{@@ _dotfile_abs_dst @@}} contains the processed dotfile absolute destination path.
  • {{@@ _dotfile_key @@}} contains the processed dotfile key.
  • {{@@ _dotfile_link @@}} contains the processed dotfile link string value.

In addition to the above, the following variables are set in each file processed by dotdrop:

  • {{@@ _dotfile_sub_abs_src @@}} contains the absolute source path of each file when handled by dotdrop.
  • {{@@ _dotfile_sub_abs_dst @@}} contains the absolute destination path of each file when handled by dotdrop.

For example, a directory dotfile (like ~/.ssh) would process several files (~/.ssh/config and ~/.ssh/authorized_keys, for example). In ~/.ssh/config:

  • _dotfile_abs_dst would be /home/user/.ssh
  • _dotfile_sub_abs_dst would be /home/user/.ssh/config

Environment variables

It's possible to access environment variables inside the templates:

{{@@ env['MY_VAR'] @@}}

This allows for storing host-specific properties and/or secrets in environment variables. It is recommended to use variables (see config variables) instead of environment variables unless these contain sensitive information that shouldn't be versioned in Git (see handle secrets doc).