diff options
author | Adam Mitz <mitza-oci@users.noreply.github.com> | 2013-07-09 15:14:04 +0000 |
---|---|---|
committer | Adam Mitz <mitza-oci@users.noreply.github.com> | 2013-07-09 15:14:04 +0000 |
commit | 7d2f01b641b22908d09fad06cbd44547e74c406d (patch) | |
tree | db58c774e9ad05b42cdb00ddafc9a249955d5421 /modules/TemplateParser.pm | |
parent | ac1a5e6af4293c41df1d6d0c40cd0bdcfbb27453 (diff) | |
download | MPC-7d2f01b641b22908d09fad06cbd44547e74c406d.tar.gz |
ChangeLogTag: Tue Jul 9 15:06:50 UTC 2013 Adam Mitz <mitza@ociweb.com>
Diffstat (limited to 'modules/TemplateParser.pm')
-rw-r--r-- | modules/TemplateParser.pm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index ed6ea26e..29d5f115 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -74,6 +74,7 @@ my %keywords = ('if' => 0, 'starts_with' => $get_type|$doif_type|$get_combined_type, 'ends_with' => $get_type|$doif_type|$get_combined_type, 'contains' => $get_type|$doif_type|$get_combined_type, + 'subst' => $get_type|$doif_type|$get_combined_type, 'remove_from' => $get_type|$perform_type|$doif_type|$perform_no_eval_type|$get_combined_type, 'compares' => $get_type|$doif_type|$get_combined_type, 'vars_equal' => $get_type|$perform_type, @@ -939,6 +940,33 @@ sub handle_contains { } +sub get_subst { + my($self, $str) = @_; + return $self->doif_subst([$str]); +} + + +sub doif_subst { + my($self, $val) = @_; + + if (defined $val) { + my($name, $pattern, $replacement) = $self->split_parameters("@$val"); + if (defined $name && defined $pattern && defined $replacement) { + my $result = $self->get_value_with_default($name); + $result =~ s/$pattern/$replacement/g; + return $result; + } + } + return undef; +} + + +sub handle_subst { + my($self, $str) = @_; + $self->generic_handle('doif_subst', $str); +} + + sub get_remove_from { my($self, $str) = @_; return $self->doif_remove_from($str); |