Skip to content

Commit

Permalink
add format to Decimal type
Browse files Browse the repository at this point in the history
add format to Decimal type

fix codesniffer issue
  • Loading branch information
saggi-dw committed May 8, 2024
1 parent 63b9cad commit 51f1ff0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions types/Decimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Decimal extends AbstractMultiBaseType
'prefix' => '',
'postfix' => '',
'engineering' => false,
'format' => '',
];

/**
Expand All @@ -37,6 +38,10 @@ class Decimal extends AbstractMultiBaseType
*/
public function renderValue($value, \Doku_Renderer $R, $mode)
{
if (preg_match("/^%(?:['+-:.]?\D?\d*\.?\d*)?[bdeEfFu]$/", $this->config['format'])) {
$R->cdata($this->config['prefix'] . sprintf($this->config['format'], $value) . $this->config['postfix']);
return true;
}

if ($this->config['engineering']) {
$unitsh = ['', 'k', 'M', 'G', 'T'];
Expand Down

0 comments on commit 51f1ff0

Please sign in to comment.