mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Convert class and style builder into a method of Template class
This commit is contained in:
parent
82b9107ca0
commit
55cafc5c33
6 changed files with 61 additions and 24 deletions
|
|
@ -471,4 +471,34 @@ class Template
|
|||
array_pop(self::$_loopvars);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute builder for v2.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param array $definition
|
||||
* @return string
|
||||
*/
|
||||
protected function _v2_buildAttribute(string $attribute, array $definition = []): string
|
||||
{
|
||||
$delimiters = [
|
||||
'class' => ' ',
|
||||
'style' => '; ',
|
||||
];
|
||||
|
||||
$values = [];
|
||||
foreach ($definition as $key => $val)
|
||||
{
|
||||
if (is_int($key) && !empty($val))
|
||||
{
|
||||
$values[] = $val;
|
||||
}
|
||||
elseif ($val)
|
||||
{
|
||||
$values[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(' %s="%s"', $attribute, escape(implode($delimiters[$attribute], $values), false));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue