dotter: Add default variable template helper
This commit is contained in:
parent
0986892dce
commit
e57cfb77fc
2 changed files with 13 additions and 0 deletions
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