summaryrefslogtreecommitdiff
path: root/php/replace.php
diff options
context:
space:
mode:
authorConnor Thomson <blumatrikz@gmail.com>2026-09-20 21:23:09 -0700
committerConnor Thomson <blumatrikz@gmail.com>2026-09-20 21:23:09 -0700
commit070a27baa8f93c3bf191459b88d24d7430a78899 (patch)
tree8c96b12d16e1d219ef410ad0e45b2d886368bc5e /php/replace.php
parent83cd353b01660f34d6fd894d15a27fb1b3aeab4c (diff)
Some fixes and updates
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) {