-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
4.4
As commented by Eloy here and here function filter_save_ignore_tags() is not so safe and would not work in the scenario:
filter_save_ignore_tags($template, array('\[\[', '##'), array('\]\]', '##'), $extracted);
|
$filteredtemplate = format_text($template, FORMAT_HTML, ['context' => $context]);
|
if (!empty($extracted)) {
|
$extracted = array_reverse($extracted); // Reversed to recover in order (in case any nesting happened).
|
$filteredtemplate = str_replace(array_keys($extracted), $extracted, $filteredtemplate);
|
}
|
What it does:
- extract special placeholders
- apply format_text
- restore special placeholders in the formatted text
Eloy also suggested to use a different syntax for temporary replacements, not using angle brackets, so format_text() does not strip them out