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

Added filters to Twig syntax #18

Merged
merged 2 commits into from
Apr 26, 2024
Merged

Added filters to Twig syntax #18

merged 2 commits into from
Apr 26, 2024

Conversation

WebVPF
Copy link
Contributor

@WebVPF WebVPF commented Apr 24, 2024

With parameters:

No parameters:

Examples

Examples of code from the documentation for verification:

{% set fruits = items|column('fruit') %}

{{ 'FR'|country_name }}
{{ 'US'|country_name('fr') }}

{{ 'EUR'|currency_name }}
{{ 'JPY'|currency_name('fr_FR') }}

{{ 'EUR'|currency_symbol }}
{{ 'JPY'|currency_symbol('fr') }}

{{ image_data|data_uri }}
{{ image_data|data_uri(mime="image/svg") }}

{{ sizes|filter(v => v > 38) }}

{{ '1000000'|format_currency('EUR') }}

{{ '2019-08-07 23:39:12'|format_date() }}
{{ '2019-08-07 23:39:12'|format_datetime() }}
{{ '2019-08-07 23:39:12'|format_time() }}

{{ '12.345'|format_number }}
{{ '12.345'|format_number({rounding_mode: 'floor'}) }}

{{ include('some_template.html.twig')|html_to_markdown }}

{{ include('some_template.inky.twig')|inky_to_html }}

{{ include('some_template.html.twig')|inline_css }}
{{ include('some_template.html.twig')|inline_css(source("some_styles.css")) }}

{{ data|json_encode() }}

{{ 'de'|language_name }}
{{ 'de'|language_name('fr') }}

{{ 'de'|locale_name }}
{{ 'de'|locale_name('fr') }}

{{ people|map(p => "#{p.first} #{p.last}")|join(', ') }}

{{ changelog|markdown_to_html }}

{{ numbers|reduce((carry, v, k) => carry + v * k) }}

{{
    "<div>
        <strong>foo</strong>
    </div>
    "|spaceless }}

{{ 'Europe/Paris'|timezone_name }}
{{ 'America/Los_Angeles'|timezone_name('fr') }}

{{ "path-seg*ment"|url_encode }}

@bennothommo
Copy link
Member

Thanks again, @WebVPF! :)

@bennothommo bennothommo merged commit dd4fb26 into wintercms:main Apr 26, 2024
@WebVPF WebVPF deleted the patch-1 branch April 26, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants