-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtemplate.cgi
More file actions
46 lines (42 loc) · 723 Bytes
/
template.cgi
File metadata and controls
46 lines (42 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
function render_template {
local _flag=0
local _line
local _t
local _code
local TL_LEAD_STR
local IFS=$'\n'
while read -r _line; do
if [[ -z "$_line" && $_flag -eq 0 ]]; then
echo
continue
fi
while [[ -n "$_line" ]]; do
if [[ $_flag -eq 0 ]]; then
_t=${_line%%<\?*}
if [[ ${#_t} -lt ${#_line} ]]; then
_flag=1
TL_LEAD_STR=$_t
echo -n "$_t"
_line=${_line#*<\?}
else
echo "$_line"
_line=""
fi
fi
if [[ $_flag -eq 1 ]]; then
_t=${_line%%\?>*}
_code="$_code$_t
"
if [[ ${#_t} -lt ${#_line} ]]; then
_flag=0
eval "$_code"
_code=""
_line=${_line#*\?>}
else
_line=""
fi
fi
done
done <$1
}