This is a performance issue for a number of reasons, but most notably, as CC has pointed out many times, because of the overhead of compilation.

There is an opportunity here to factor out common code in the same way thet TWiki::Func does.

One of my favourite code fragments is :-
sub replaceVars {
  my ($format, $data) = @_;

  if (defined $data) {
    if (defined $data->{wikiname}) {
      $data->{username} = &TWiki::Func::wikiToUserName($data->{wikiname});
      $data->{wikiusername} = &TWiki::Func::userToWikiName($data->{wikiname});

    foreach my $key (keys %$data) {
      $format =~ s/\$$key/$data->{$key}/g;

  $format =~ s/\$n\b/\n/g;
  $format =~ s/\$quot\b/\"/gos;
  $format =~ s/\$percnt\b/\%/gos;
  $format =~ s/\$dollar\b/\$/gos;

  return $format;

Is this better as a core module or a Contrib?

ItemTemplate edit

Summary Extensive code duplication across Plugins
ReportedBy TWiki:Main.AntonAylward
SVN Range Thu, 02 Feb 2006 build 8675
AppliesTo Extension
Component Many plugins
Priority Enhancement
CurrentState New
TargetRelease major
Topic revision: r5 - 11 Dec 2008, UnknownUser
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License