wintercms / vscode-extension

Official Winter CMS VSCode extension
https://marketplace.visualstudio.com/items?itemName=wintercms.winter-cms
MIT License
10 stars 6 forks source link

Added filters to Twig syntax #18

Closed WebVPF closed 7 months ago

WebVPF commented 7 months ago

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 commented 7 months ago

Thanks again, @WebVPF! :)