SID-00596: Include and Replace
I want to INCLUDE a TWiki-Page and apply a substitution on the included text.
Example:
Text to on the page to include: "A|B|C". Text to appear on the page which includes the text: "A, B, C".
How can I do that?
--
TWikiGuest - 2009-10-28
Discussion and Answer
You can do that with the EXTRACT function of
FilterPlugin. The official documentation is a bit sparse, so you might want to check out my reworking of its examples at
TWikibug:Item6085
.
--
SeanCMorgan - 2009-10-28
Or include it into a
SpreadSheetPlugin formula, such as
%CALC{$FORMULA1($FORMULA2($FORMULA3(%INCLUDE{FooBar}%)))}%. Make sure the included page does not contain any newlines.
More at
VarINCLUDE,
VarCALC. Remotely related examples at
DashboardWithDynamicTable,
DashboardWithDynamicInclude.
--
PeterThoeny - 2009-10-28
Thanks! That solves my current problem. My example above was the wrong way around. Actually I need to translate "A, B, C" to "|A| |B| |C|". That could I do with the
SpreadSheetPlugin.
But what if I had to do replacements on less structured input or what if the text contains newlines?
The INCLUDE variable supports the parameter "pattern". What about a parameter "replacement"? If specified every ouccurance of "pattern" would be replaced by "replacement". Wouldn't that a nice and helpful feature?
--
TWikiGuest - 2009-10-29
That would be a useful enhancement. You can file a feature request (link is sidebar). If you know Perl you could provide a patch - the fastest way to get a feature accepted.
--
PeterThoeny - 2009-10-29
I've tried to create a feature request, but I've no CHANGE permission for Codev. Neither with
TWikiGuest nor with a new registered account. In my opinion to create a feature request should not require developer permissions.
Here is my feature request. I would glad, if somebody with developer permissions may enter it. If done, please set the status of this page to "Answered question" again. Thanks in advance.
ReplaceParameterForIncludeVariable
Introduce new parameter "replace" to INCLUDE variable
If you include a web-page to a TWiki page you possibly need to do some replacements, e.g. to remove superfluous or add missing html-code.
If you include a foreign page you can't use the existing parameter replacement mechanism (%PARONE%, %PARTWO%, ...).
The INCLUDE variable should be support one or more parameter pairs "patternN" and "replacementN". If specified every occurrence of "patternN" should be replaced by "replacementN". Replacement mode "text" oder "regex" should be selectable. That would by useful feature!
See also
http://twiki.org/cgi-bin/view/Support/SID-00596
Vars
--
TWikiGuest - 2009-10-30
Please!
--
TWikiGuest - 2009-11-02
What is your twiki.org user name? I can add you to the
TWikiCommunityGroup.
--
PeterThoeny - 2009-11-02
My user name is
HorstEsser.
--
TWikiGuest - 2009-11-02
I added
HorstEsser to the
TWikiCommunityGroup.
--
PeterThoeny - 2009-11-11
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2010-01-03
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.