Adds separate functions for yaml header and yaml file
This commit is contained in:
parent
51ca57da7f
commit
ccbb335ec4
1 changed files with 19 additions and 2 deletions
19
inc/yaml
19
inc/yaml
|
@ -8,12 +8,29 @@ getYamlBlock(){
|
|||
|
||||
# If there is a yaml file, use it
|
||||
# if not, try and get the yaml header
|
||||
getYamlFile || getYamlHeader
|
||||
}
|
||||
|
||||
getYamlFile(){
|
||||
vecho "getYamlFile $*"
|
||||
cd "$dataDir" || return
|
||||
local filename
|
||||
filename="$(findFile "$1")"
|
||||
if [ -f "$filename.yaml" ]; then
|
||||
cat "$filename.yaml"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
getYamlHeader(){
|
||||
vecho "getYamlHeader $*"
|
||||
cd "$dataDir" || return
|
||||
local filename
|
||||
filename="$(findFile "$1")"
|
||||
sed -n '1 { /^---/ { :a N; /\n---/! ba; p} }' "$filename" |
|
||||
sed '1d;$d;s/\t/ /g'
|
||||
fi
|
||||
}
|
||||
|
||||
getYamlTitle(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue