From e1d02f1354a105d96064e0799739fde94027bee8 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 21 May 2023 21:48:57 -0700 Subject: [PATCH] (dev/core#4303) Allow {htxt} guard to accommodate variable ID Before ------ `{htxt}` guard works with static IDs (`{htxt id="abc"}`) After ----- `{htxt}` guard with with variable ID (`{htxt id=$abc}`) Comments -------- As discussed in dev/core#4303, one relevant use-case comes from `CustomField.hlp`. In my copy of universe, there's a similar construction in `nz.co.fuzion.entitysetting` (`entitysettingscommon.hlp`). --- CRM/Core/Smarty/plugins/prefilter.htxtFilter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CRM/Core/Smarty/plugins/prefilter.htxtFilter.php b/CRM/Core/Smarty/plugins/prefilter.htxtFilter.php index 1a2a56a085..c7fdac2c20 100644 --- a/CRM/Core/Smarty/plugins/prefilter.htxtFilter.php +++ b/CRM/Core/Smarty/plugins/prefilter.htxtFilter.php @@ -22,6 +22,10 @@ function smarty_prefilter_htxtFilter($tpl_source, &$smarty) { $htxts++; return sprintf('{if $id == %s}%s', $m[1], $m[0]); }, + '/\{htxt id=(\$\w+)}/' => function ($m) use (&$htxts) { + $htxts++; + return sprintf('{if $id == %s}%s', $m[1], $m[0]); + }, ';\{/htxt\};' => function($m) use (&$_htxts) { $_htxts++; return '{/htxt}{/if}'; -- 2.25.1