Skip to content

2.x Update Timber Object Getter function names in Twig#2170

Closed
gchtr wants to merge 76 commits into2.x-factoriesfrom
2.x-twig-get-functions
Closed

2.x Update Timber Object Getter function names in Twig#2170
gchtr wants to merge 76 commits into2.x-factoriesfrom
2.x-twig-get-functions

Conversation

@gchtr
Copy link
Copy Markdown
Member

@gchtr gchtr commented Jan 12, 2020

Ticket: #2144

Issue

See #2144.

Solution

  • Added new Twig functions for the relevant Timber::get_* functions.
  • Updated the deprecation warnings. There’s now always two possibilities. Instead of Post(), it can either be get_post() or get_posts(), depending on what’s at hand. The same goes for Term and User.
  • I deliberately removed the {{ Attachment() }} function as well as deprecated the {{ Image() }} function without replacement, because we can use {{ get_post() }} and {{ get_posts() }}. The Class Maps will handle returning either a Timber\Image or Timber\Attachment.

Impact

A more unified way of interacting with Timber’s API throughout PHP and Twig.

Usage Changes

New function names. Pretty much the same functionality, except for handling singular and multiple objects.

Considerations

Should we add Twig functions for the special-case Timber::get_* functions, like Timber::get_user_by() or Timber::get_post_by_slug(). I think, currently we don’t have to do that.

Testing

Tests are currently breaking. They will only run without errors as soon as we merge object factories into the 2.x branch.

Todo

  • Add testing for comment functions in Twig.
  • Resolve todos.

szepeviktor and others added 30 commits December 10, 2019 22:45
Provide notice for min. WordPress version
@acobster acobster changed the base branch from 2.x to 2.x-factories January 17, 2020 23:48
@gchtr
Copy link
Copy Markdown
Member Author

gchtr commented Jan 18, 2020

Added as a new pull request in #2178.

@gchtr gchtr closed this Jan 18, 2020
@nlemoine nlemoine deleted the 2.x-twig-get-functions branch June 23, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants