dotter: Add default variable template helper
This commit is contained in:
parent
0986892dce
commit
e57cfb77fc
2 changed files with 13 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
default_target_type = "symbolic"
|
default_target_type = "symbolic"
|
||||||
|
|
||||||
[helpers]
|
[helpers]
|
||||||
|
with_default = ".dotter/helpers/var_with_default.rhai"
|
||||||
|
|
||||||
# BASE: A base system. Sets up a nice xdg (zsh) shell environment, utility scripts and
|
# BASE: A base system. Sets up a nice xdg (zsh) shell environment, utility scripts and
|
||||||
# a development environment based on git and nvim.
|
# a development environment based on git and nvim.
|
||||||
|
|
|
||||||
12
.dotter/helpers/var_with_default.rhai
Normal file
12
.dotter/helpers/var_with_default.rhai
Normal file
|
|
@ -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])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue