1
0
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:
Erik Flodin
2025-03-20 22:03:33 +01:00
parent bbb58e6625
commit 638c035eee
4 changed files with 51 additions and 1 deletions

14
yadm
View File

@@ -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]) }