You are here: Foswiki>Tasks Web>Item1641 (05 Jan 2015, GeorgeClark)Edit Attach
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
Codebase
SVN Range Thu, 02 Feb 2006 build 8675
AppliesTo Extension
Component
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease major
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release01x01Checkins
Topic revision: r6 - 05 Jan 2015, GeorgeClark - This page was cached on 30 Aug 2015 - 01:28. Get a fresh version here.
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License