summaryrefslogtreecommitdiff
path: root/php/replace.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/replace.php')
-rwxr-xr-xphp/replace.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/php/replace.php b/php/replace.php
index dcc5fb6..0823370 100755
--- a/php/replace.php
+++ b/php/replace.php
@@ -25,6 +25,12 @@ function replace(string $templatePath, array $replacements = []): string {
foreach ($replacements as $placeholder => $replacementValue) {
$replacementValue = tidy((string)$replacementValue);
+ if ($replacementValue === '') {
+ $pattern = '/^[ \t]*' . preg_quote($placeholder, '/') . '[ \t]*\n?/m';
+
+ $html = preg_replace($pattern, '', $html);
+ }
+
$pattern = '/^([ \t]*)' . preg_quote($placeholder, '/') . '/m';
$html = preg_replace_callback($pattern, function (array $match) use ($replacementValue) {