Mohammad,

As is commonly the case, especially in TiddlyWiki, it is important to 
return to why we are asking to do something. It is actually very common for 
people to think search and replaces is the answer when another solution may 
be more valid. In part because a *manual search and replace* is easier for 
one or two cases, *automated replacements* re a better solution for 
multiple cases, so *automating search and replace* is not often overly 
useful.

This does not replace the feature you are looking for, it just potentially 
diminishes the value, or number of occasions it may be needed.

<$set name=first-name value="Mohammad">
<$set name=last-name value="TheMan">
<$set name=birthday value="26/12">
<$set name=salution value="Sir">

<$transclude tiddler="letter-template"/>


</$set></$set></$set>

letter-template
Dear <<salutation>> <<first-name>>  <<last-name>>,

We are aware your birthday is on the <<birthday>> and would like to give 
you the following gift, <<giftname>>
...

The key to making such productivity gains with TiddlyWiki is to always be 
thinking of how you can capture and represent data in the first place in a 
way that future retrofit or customisation is easier.

I applaud your building the tools for such retrofit, but also think it is 
important to avoid such a need in the first place. In this example if we 
foresaw the need to search and replace something more than once, we can 
consider if we should construct our template instead. If it is only once, 
manual change is cheap and practical.

By the way, if you had not thought of the need to change those values when 
you first wrote the tiddler, perhaps when you identify you need to search 
and replaces rather than change the literal value, change it to a variable 
instead.

So Search for "Mohammad" and replace with <<first-name>> 
or perhaps "Mohammad" and replace with {{!!first-name}} 
would be the optimum approach.

*So perhaps you can ensure any search and replace solution is tolerant of 
Variables and text references, perhaps even substitution variables $param$ 
$(variable)$*

Regards
Tony





On Saturday, February 23, 2019 at 7:06:44 PM UTC+11, Mohammad wrote:
>
> Consider myTid tiddler has the below content:
>
> This is a test
>
> * one
> * two
>
>
>
>
> and then, the below script does some small processing like adding some 
> prefixes.
>
>
> <$vars x={{myTid!!text}} >
> <$list filter="[<x>addprefix[xx]]">
>
> </$list>
>
> And the result:
>
>
> xxThis is a test * one * two
>
>
> Is there any way to keep whitespace and linebreaks?
> This may seems useless but it is used when you want to process the text 
> filed of a tiddler has paragraphs.
>
> --Mohammad
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a28637e6-d30d-4f43-95f6-7e10c8bac867%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to