add pre_deploy.sh script for dotter
This commit is contained in:
parent
808cdb3201
commit
d93bf44ae0
7 changed files with 192 additions and 16 deletions
30
.dotter/handlebars_helpers/flatten_table.rhai
Normal file
30
.dotter/handlebars_helpers/flatten_table.rhai
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Flatten a table into a list of values.
|
||||
* The table has to be in the form of
|
||||
* ```toml
|
||||
* [table.subtable]
|
||||
* variable1 = ["value1", "value2"]
|
||||
*
|
||||
* [table.subtable]
|
||||
* variable2 = ["value3", "value4"]
|
||||
*
|
||||
* then we use it in handlerbars like this:
|
||||
*
|
||||
* {{ flatten_table table.subtable }}
|
||||
*
|
||||
* and it will return an array with all the arrays of subtable
|
||||
*/
|
||||
|
||||
if type_of(params[0]) != "map" {
|
||||
return;
|
||||
}
|
||||
|
||||
let table = params[0];
|
||||
|
||||
let result = [];
|
||||
|
||||
for value in table.values() {
|
||||
result.append(value);
|
||||
}
|
||||
|
||||
result
|
||||
48
.dotter/handlebars_helpers/header.rhai
Normal file
48
.dotter/handlebars_helpers/header.rhai
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
let x_padding = hash["padding"] ?? 50;
|
||||
|
||||
let header = #{
|
||||
x_padding: x_padding,
|
||||
out: "",
|
||||
append: |suffix| {
|
||||
this.out += suffix + "\n";
|
||||
},
|
||||
append_center: |suffix| {
|
||||
|
||||
let suffix_len = suffix.len();
|
||||
let padding = this.x_padding - suffix_len / 2;
|
||||
let fill = "";
|
||||
fill.pad(padding, " ");
|
||||
|
||||
this.out += fill + suffix.to_upper() + fill + "\n";
|
||||
},
|
||||
append_divider: || {
|
||||
let divider = "";
|
||||
divider.pad(this.x_padding * 2, "─");
|
||||
|
||||
this.append(divider);
|
||||
},
|
||||
open_echo: || {
|
||||
this.out += "echo -e '\n";
|
||||
},
|
||||
close_echo: || {
|
||||
this.out += "'";
|
||||
},
|
||||
to_string: || {
|
||||
return this.out;
|
||||
}
|
||||
};
|
||||
|
||||
header.open_echo();
|
||||
|
||||
header.append_divider();
|
||||
|
||||
|
||||
params.for_each(|idx| {
|
||||
header.append_center(this);
|
||||
});
|
||||
|
||||
header.append_divider();
|
||||
header.close_echo();
|
||||
|
||||
return header.to_string();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue