Skip to main content

Templating

You can use handlebars template syntax in dot.yaml files and the defaults file.

This allows for e.g. access to environment variables.

Variables

VariableDescriptionExample
configThe current configdepends: [ {{#each config.variables.some ~}} "{{this}}", {{/each }} ]
envA map of Environment variablessome.file: {{ env.HOME }}/some.file
nameThe name of the current dotinstalls: apt install {{ name }}
osThe current os (either windows, linux or darwin) as used in dots{{#if (eq os "windows")}}some: value{{/if}}
whoamiA map of information about the environment (see whoami). Provided by the whoami crate.some.file: /home/{{ whoami.username }}/some.file
directoriesA map of directories (see directories). Provided by the directories cratesome.file: {{ directories.home }}/some.file

whoami

VariableDescription
desktop_envInformation about the Desktop environment
devicenameThe device name
distroThe os distro
hostnameThe hostname
langAn array of the users prefered languages
platformThe current platform
realnameThe users full name
usernameThe current users username
archThe CPU architecture of the system.

directories

GroupVariable
basecache
baseconfig
basedata
basedata_local
basehome
basepreference
useraudio
userdesktop
userdocument
userdownload
userhome
userpicture
userpublic
usertemplate
uservideo

Helpers

Rotz comes with helpers provided by the handlebars_misc_helpers crate.

Theres also a number of inbuilt helpers provided

#windows, #linx and #darwin

These helpers are shorthands for checking the curent os.

Instea of {{ #if (eq os "windows") }}{{ else }}{{ /if }} they can be used like this {{ #windows }}{{ else }}{{ /windows }}.

eval

The eval helper can be used to evalate a string on the shell configured by shell_command.

The helper can be used like this {{ eval "some --shell command" }}