mirror of
https://github.com/flynx/photobook.git
synced 2025-12-24 20:21:58 +00:00
mostly done with new dynamic teplate generation...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c21fb0bbf8
commit
f5c1c8c968
@ -229,7 +229,7 @@ templateVars(){
|
|||||||
# cache the vars...
|
# cache the vars...
|
||||||
if [ ${TEMPLATE_INDEX[$1]+_} ] ; then
|
if [ ${TEMPLATE_INDEX[$1]+_} ] ; then
|
||||||
TEMPLATE_INDEX[$1]=$(cat "$1" \
|
TEMPLATE_INDEX[$1]=$(cat "$1" \
|
||||||
| grep -o '\${[A-Z0-9]\+}' \
|
| grep -o '\${[A-Z0-9_]\+}' \
|
||||||
| sed 's/\${\(.*\)}/\1/g' \
|
| sed 's/\${\(.*\)}/\1/g' \
|
||||||
| sort)
|
| sort)
|
||||||
fi
|
fi
|
||||||
@ -242,6 +242,30 @@ indexTemplates(){
|
|||||||
templateVars "${tpl}" > /dev/null
|
templateVars "${tpl}" > /dev/null
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
# this depends on $img and $txt arrays being defined...
|
||||||
|
populateTemplate(){
|
||||||
|
local tpl="$1"
|
||||||
|
local slots=( $(templateSlots "${tpl}") )
|
||||||
|
local text=$(cat "${tpl}")
|
||||||
|
|
||||||
|
local var
|
||||||
|
local i=0
|
||||||
|
local t=0
|
||||||
|
# XXX can we do this in a single pass???
|
||||||
|
for var in ${slots[@]} ; do
|
||||||
|
local name=${var//[0-9]/}
|
||||||
|
if [ ${name} = "IMAGE" ] ; then
|
||||||
|
local val=${img[$i]}
|
||||||
|
i=$(( n + 1 ))
|
||||||
|
else
|
||||||
|
local val=${txt[$t]}
|
||||||
|
t=$(( n + 1 ))
|
||||||
|
fi
|
||||||
|
text=$(echo -e "${text}" | \
|
||||||
|
sed "s/\${${var}}/${val}/g")
|
||||||
|
done
|
||||||
|
echo -e "${text}"
|
||||||
|
}
|
||||||
|
|
||||||
getTemplate(){
|
getTemplate(){
|
||||||
local SPREAD=$1
|
local SPREAD=$1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user