mirror of
https://github.com/TheLocehiliosan/yadm
synced 2026-03-02 03:49:29 +00:00
Add support for running commands from default template processor
In a default template, "{% command something arg1 ... argN %}" will be
replaced by the first line output from the command "something" run with
the given arguments (#452).
This commit is contained in:
14
yadm
14
yadm
@@ -436,7 +436,19 @@ BEGIN {
|
||||
filename[++current] = include
|
||||
line[current] = 0
|
||||
}
|
||||
else { print }
|
||||
else {
|
||||
if (match($0, /\{%[ \t]*command[ \t]+/)) {
|
||||
prefix = substr($0, 0, RSTART - 1)
|
||||
command = substr($0, RSTART + RLENGTH)
|
||||
if (match(command, /[ \t]*%\}/) && RSTART > 1) {
|
||||
suffix = substr(command, RSTART + RLENGTH)
|
||||
command = substr(command, 0, RSTART - 1)
|
||||
command | getline
|
||||
$0 = prefix $0 suffix
|
||||
}
|
||||
}
|
||||
print
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res >= 0) { close(filename[current]) }
|
||||
|
||||
Reference in New Issue
Block a user