Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] ReplaceViewHelper #863

Merged
merged 1 commit into from
Mar 20, 2024
Merged

[FEATURE] ReplaceViewHelper #863

merged 1 commit into from
Mar 20, 2024

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Mar 15, 2024

The ReplaceViewHelper replaces one or multiple strings with other strings. This ViewHelper mimicks PHP's :php:str_replace() function. However, it's also possible to provide replace pairs as associative array via the "replace" argument.

Replace a single string:

<f:replace value="Hello World" search="World" replace="Fluid" /> <!-- Output: Hello Fluid -->

Replace multiple strings:

<f:replace value="Hello World" search="{0: 'World', 1: 'Hello'}" replace="{0: 'Fluid', 1: 'Hi'}" /> <!-- Output: Hi Fluid -->

Replace multiple strings using associative array:

<f:replace value="Hello World" replace="{'World': 'Fluid', 'Hello': 'Hi'}" /> <!-- Output: Hi Fluid -->

@s2b s2b force-pushed the feature/replaceViewHelper branch 2 times, most recently from e6c5c47 to c67cc3b Compare March 20, 2024 15:39
The ReplaceViewHelper replaces one or multiple strings with other
strings. This ViewHelper mimicks PHP's :php:`str_replace()` function.
However, it's also possible to provide replace pairs as associative array
via the "replace" argument.

Replace a single string:

```xml
<f:replace value="Hello World" search="World" replace="Fluid" /> <!-- Output: Hello Fluid -->
```

Replace multiple strings:

```xml
<f:replace value="Hello World" search="{0: 'World', 1: 'Hello'}" replace="{0: 'Fluid', 1: 'Hi'}" /> <!-- Output: Hi Fluid -->
```

Replace multiple strings using associative array:

```xml
<f:replace value="Hello World" replace="{'World': 'Fluid', 'Hello': 'Hi'}" /> <!-- Output: Hi Fluid -->
```
@s2b s2b force-pushed the feature/replaceViewHelper branch from c67cc3b to 58bda42 Compare March 20, 2024 15:48
@s2b s2b merged commit 37dbc0d into main Mar 20, 2024
6 checks passed
@s2b s2b deleted the feature/replaceViewHelper branch March 20, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants