mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
Utility function to add prefix to placeholder & optionally wrap it with markers, because I was writing it out so many times
This commit is contained in:
parent
f6b7dc1474
commit
47cf12869b
@ -1654,6 +1654,30 @@ abstract class Merge
|
||||
return $replacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix a placeholder, taking care of $$ or {{}} markers
|
||||
*
|
||||
* @param string $prefix Placeholder prefix
|
||||
* @param string $placeholder Placeholder, with or without {{...}} or $$...$$ markers
|
||||
* @param null|string $wrap "{" or "$" to add markers, omit to exclude markers
|
||||
* @return string
|
||||
*/
|
||||
protected function prefix($prefix, $placeholder, $wrap = null)
|
||||
{
|
||||
$marker = ['', ''];
|
||||
if($placeholder[0] == '{' && is_null($wrap) || $wrap[0] == '{')
|
||||
{
|
||||
$marker = ['{{', '}}'];
|
||||
}
|
||||
elseif($placeholder[0] == '$' && is_null($wrap) || $wrap[0] == '$')
|
||||
{
|
||||
$marker = ['$$', '$$'];
|
||||
}
|
||||
|
||||
$placeholder = str_replace(['{{', '}}', '$$'], '', $placeholder);
|
||||
return $marker[0] . ($prefix ? $prefix . '/' : '') . $placeholder . $marker[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process special flags, such as IF or NELF
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user