diff --git a/.dotter/global.toml b/.dotter/global.toml index 69d2ab9..f85bfe2 100644 --- a/.dotter/global.toml +++ b/.dotter/global.toml @@ -4,6 +4,7 @@ default_target_type = "symbolic" [helpers] +with_default = ".dotter/helpers/var_with_default.rhai" # BASE: A base system. Sets up a nice xdg (zsh) shell environment, utility scripts and # a development environment based on git and nvim. diff --git a/.dotter/helpers/var_with_default.rhai b/.dotter/helpers/var_with_default.rhai new file mode 100644 index 0000000..1d4858b --- /dev/null +++ b/.dotter/helpers/var_with_default.rhai @@ -0,0 +1,12 @@ +// tests the type of variable passed in +// if 'no' type (does not exist or cant be parsed) +// we return the second, 'default' variable + +fn choose(a, b) { + if type_of(a) != "()" { + return a; + } + return b; +} + +choose(params[0], params[1])