Skip to content

Conversation

@jaxwilko
Copy link
Member

@jaxwilko jaxwilko commented Feb 1, 2022

This PR adds an asset filter to twig.

{{ 'path/to/asset.png' | asset }}
// this is the equivilant to the blade
{{ asset('path/to/asset.png') }}

@LukeTowers LukeTowers added Status: In Progress enhancement PRs that implement a new feature or substantial change labels Feb 1, 2022
@LukeTowers LukeTowers added this to the v1.1.8 milestone Feb 1, 2022
@bennothommo bennothommo marked this pull request as draft February 7, 2022 01:05
@jaxwilko
Copy link
Member Author

jaxwilko commented Feb 7, 2022

Note: This PR now additionally includes mirroring system filters as functions

This change introduces the following functionality within twig templates:

  • app - {{ 'path/to/link' | app }} or {{ app('path/to/link') }}
  • media - {{ 'path/to/file.png' | media }} or {{ media('path/to/file.png') }}
  • asset - {{ 'path/to/file.png' | asset }} or {{ asset('path/to/file.png') }}
  • resize - {{ 'path/to/file.png' | resize }} or {{ resize('path/to/file.png') }}
  • imageWidth - {{ 'path/to/file.png' | imageWidth }} or {{ imageWidth('path/to/file.png') }}
  • imageHeight - {{ 'path/to/file.png' | imageHeight }} or {{ imageHeight('path/to/file.png') }}

@LukeTowers LukeTowers marked this pull request as ready for review February 7, 2022 01:26
@LukeTowers LukeTowers merged commit d96231c into develop Feb 7, 2022
@LukeTowers LukeTowers deleted the asset-filter branch February 7, 2022 01:30
LukeTowers added a commit that referenced this pull request Feb 8, 2022
* develop: (25 commits)
  Use the asset helper for static assets
  Added asset filter & function versions of all System Twig filters (#428)
  Improve Japanese Translation (#435)
  Improved Latvian translation (#434)
  Improved Ukrainian translation (#433)
  Redirect to the myaccount page as a final fallback
  Improve Persian translations (#423)
  typo fix (#424)
  Improved Russian translation (#422)
  Tidy up
  Style fix
  Go to User's details page when clicking on related user from the roles update page
  Update recommend format for implementing controller behaviors
  Add support for default configuration file names for controller behaviors
  Attach default permissions to the publisher role
  Only show role user management in the update context
  Improve UserRole editing experience
  Fix support for readOnly on the datepicker formwidget.
  Sort assets alphabetically in the CMS Theme Editor (#420)
  VSCode recommended extensions (#417)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs that implement a new feature or substantial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants