Skip to content

Commit

Permalink
Added new variable modifier for template class
Browse files Browse the repository at this point in the history
Added :h Call which strip_tags on the variable before output.
  • Loading branch information
eSilverStrike committed Nov 26, 2018
1 parent e87eab0 commit bce96ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions system/classes/template.class.php
Expand Up @@ -1460,6 +1460,10 @@ function mod_echo($val, $modifier = '')
case 's':
$ret = htmlspecialchars($ret);
break;

case 'h':
$ret = strip_tags($ret);
break;

case 't':
$ret = substr($ret, 0, intval(substr($mod, 1))); // truncate
Expand Down Expand Up @@ -1568,7 +1572,7 @@ private function replace_vars($tmplt, $in_php = false)
$tmplt = preg_replace(
array(
'/\{([-\.\w\d_\[\]]+)\}/', // matches {identifier}
'/\{([-\.\w\d_\[\]]+)((:u|:s|:t\d+)+)\}/', // matches {identifier} with optional :s, :u or :t### suffix
'/\{([-\.\w\d_\[\]]+)((:u|:s|:h|:t\d+)+)\}/', // matches {identifier} with optional :s, :u or :t### suffix
),
array(
'$this->get_var(\'\1\')',
Expand All @@ -1579,7 +1583,7 @@ private function replace_vars($tmplt, $in_php = false)
$tmplt = preg_replace(
array(
'/\{([-\.\w\d_\[\]]+)\}/', // matches {identifier}
'/\{([-\.\w\d_\[\]]+)((:u|:s|:t\d+)+)\}/', // matches {identifier} with optional :s, :u or :t### suffix
'/\{([-\.\w\d_\[\]]+)((:u|:s|:h|:t\d+)+)\}/', // matches {identifier} with optional :s, :u or :t### suffix
),
array(
'<?php echo $this->val_echo(\'\1\'); ?>',
Expand Down

0 comments on commit bce96ff

Please sign in to comment.