-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wintercms:develop' into patch-1
- Loading branch information
Showing
16 changed files
with
264 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 #} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# time_since and time_tense | ||
|
||
The `time_since` and `time_tense` filters format time. | ||
|
||
## time_since | ||
|
||
Formats a human readable time difference from the value to the current time. Eg: **10 minutes ago** | ||
|
||
```twig | ||
{{ '2021-03-06 14:25:55'|time_since }} | ||
{{ 'February 14, 2024 14:30'|time_since }} | ||
``` | ||
|
||
## time_tense | ||
|
||
Formats 24-hour time and the day using the grammatical tense of the current time. Eg: Today at 12:49, Yesterday at 4:00 or 18 Sep 2015 at 14:33. | ||
|
||
```twig | ||
{{ '2021-03-06 14:25:55'|time_tense }} | ||
``` | ||
|
||
> **NOTE:** To format dates in Twig there is a [date filter](https://twig.symfony.com/doc/3.x/filters/date.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# url_*() | ||
|
||
## url() | ||
|
||
The `url()` function generates a fully qualified URL to the given path. | ||
|
||
```twig | ||
{{ url('blog') }} | ||
{# https://site.com/blog #} | ||
``` | ||
|
||
You can specify a variable as a function parameter: | ||
|
||
```twig | ||
{{ url(category.slug) }} | ||
{# https://site.com/slug-value #} | ||
``` | ||
|
||
In function parameters you can use concatenation: | ||
|
||
```twig | ||
{{ url('blog/post/' ~ post.id) }} | ||
{# https://site.com/blog/post/123 #} | ||
``` | ||
|
||
### Base URL | ||
|
||
You can get the base url like this: | ||
|
||
```twig | ||
{{ url('/') }} | ||
{# https://site.com/ #} | ||
``` | ||
|
||
## url_current() | ||
|
||
The `url_current()` function generates a fully qualified URL to the current path. Syntax: | ||
|
||
```twig | ||
{{ url_current() }} | ||
``` | ||
|
||
An example of generating a canonical link using the `url_current()` function and the `|lower` Twig filter: | ||
|
||
```twig | ||
<link rel="canonical" href="{{ url_current()|lower }}" /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.