#1 2009-04-16 13:54:39

Gocom
Moderator
omega
Real name: Jukka Svahn
From: Finland
Known languages: EN, FI
Website

rah_replace

The plugin, rah_replace, returns contained content with all occurances replaces with given replacements. It supports multiple replacemens.

<txp:rah_replace from="something,to,change" to="into">
	This is something that is going to change into.
</txp:rah_replace>

Already a bit older(ish) plugin of mine. Noticed that it didn’t have a support topic, so decided to create one. Also, today is the day when rah_replace got it’s first update; Version 0.2 adds delimiter attribute.

More info and downloads.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Online

 

#2 2009-08-16 20:47:00

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: rah_replace

Hi Jukka, nice plugin, thanks! Is it possible to replace line endings (\r\n etcetera) as well? I tried it using all kind of quotes, but can’t get it to work. I’m trying to use it around the output_form tag in <body class="<txp:output_form form="body_class" />">. The form contains a lot of conditional tags, so in the end the output is something like this:

<body class="

[lots of blank lines]

class-name

[more lots of blank lines]

">

And yes, I can remove the line endings from my form, but for legibility I’d rather not do that.


<txp:Els /> ;)
Tag Reference

Offline

 

#3 2009-08-16 21:21:26

ruud
Developer emeritus
omega
Real name: Ruud van Melick
From: a galaxy far far away
Known languages: li,nl,en,(de)
Website

Re: rah_replace

<body class="<txp:php>echo str_replace("\r\n", '', output_form(array('form'=>'body_class')));</txp:php>">

edit: fixed code

Last edited by ruud (2009-08-16 22:07:34)

Offline

 

#4 2009-08-16 21:34:59

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: rah_replace

Thanks, Ruud :) But:

<body class="<br />
<b>Warning</b>:  Unexpected character in input:  '\' (ASCII=92) state=1 in <b>/path/to/textpattern/publish/taghandlers.php(3127) : eval()'d code</b> on line <b>1</b><br />
<br />
<b>Parse error</b>:  syntax error, unexpected T_STRING in <b>/path/to/textpattern/publish/taghandlers.php(3127) : eval()'d code</b> on line <b>1</b><br />
">

<txp:Els /> ;)
Tag Reference

Offline

 

#5 2009-08-16 22:01:34

Gocom
Moderator
omega
Real name: Jukka Svahn
From: Finland
Known languages: EN, FI
Website

Re: rah_replace

Els wrote:

Hi Jukka, nice plugin, thanks! Is it possible to replace line endings (\r\n etcetera) as well?

Well not literally, but you can really easily replace line breaks. For example:

<txp:rah_replace from="
" to="">
1
2
3
</txp:rah_replace>

becomes:

123

Last edited by Gocom (2009-08-16 22:08:37)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Online

 

#6 2009-08-16 22:09:36

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: rah_replace

Ah, I see, thanks. Meanwhile, Ruud solved the problem elsewhere, so I won’t be needing rah_replace at the moment. But I’ll certainly keep it in mind!


<txp:Els /> ;)
Tag Reference

Offline

 

Powered by PunBB
© Copyright 2002 – 2005 Rickard Andersson