sub preprocess()

in src/lib/view.pm [95:108]


sub preprocess {
    my $text = shift;
    my @params = shift;
    while($text =~ /\{\{\w+(?:\([^(){}]*\))?\}\}/)
    {
        my ($before, $tag, $after) = ($`, $&, $');
        $tag =~ s/^\{\{|\}\}$//g;
        $tag =~ m/(\w+)(?:\(([^()]*)\))?/;
        my ($method, $args) = ($1, $2);
        my $replacement = &{\&{$method}}($args) or debug "could not find tag sub $tag";
        $text = $before . $replacement . $after;
    }
    return $text;
}