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

Add markup docs Str filters #174

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions markup/filters/str.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Strings

Winter CMS provides Twig filters for working with strings. These filters are identical to the global PHP helper functions that are documented in [Helpers > Strings](../../docs/services/helpers#strings) section.

## camel

The `camel` filter converts the given string to camelCase:

```twig
{{ 'test test'|camel }}

{# testTest #}
```

## finish

The `finish` filter adds a single instance of the given value to a string:

```twig
{{ 'test'|finish('/') }}

{# test/ #}
```

## plural

The `plural` filter converts a string to its plural form. This filter currently only supports the English language:

```twig
{{ 'test'|plural }}

{# tests #}
```

## singular

The `singular` filter converts a string to its singular form. This filter currently only supports the English language:

```twig
{{ 'letters'|singular }}

{# letter #}
```

## slug

The `slug` filter generates a URL friendly "slug" from the given string:

```twig
{{ 'test test'|slug }} {# test-test #}

{{ 'test_test'|slug }} {# test-test #}

{{ 'test test'|slug('+') }} {# test+test #}
```

## snake

The `snake` filter converts the given string to snake_case:

```twig
{{ 'test test'|snake }}

{# test_test #}
```

## studly

The `studly` filter converts the given string to StudlyCase:

```twig
{{ 'test test'|studly }}

{# TestTest #}
```
1 change: 1 addition & 0 deletions markup/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sections:
filters/page: "| page"
filters/raw: "| raw"
filters/resize: "| resize"
filters/str: "| str*"
filters/theme: "| theme"
filters/time: "| time_[since|tense]"
filters/trans: "| trans"
Expand Down
Loading