-
-
Notifications
You must be signed in to change notification settings - Fork 356
[Turbo] Add Twig Extensions for meta
tags
#2618
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, can you also add some tests and update the CHANGELOG (for 2.24)?
Thanks!
PS: please for the next time, keep the PR template 🙏🏻
return $this->turboRefreshMethod($method).$this->turboRefreshScroll($scroll); | ||
} | ||
|
||
public function turboRefreshMethod(string $method = self::REFRESH_METHOD_REPLACE): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some PHPDoc and a link to the documentation
return \sprintf('<meta name="turbo-refresh-method" content="%s">', $method); | ||
} | ||
|
||
public function turboRefreshScroll(string $scroll = self::REFRESH_SCROLL_RESET): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some PHPDoc and a link to the documentation
I don't think we need to have 3 methods here. What about keeping just the first two ? Also i would not set the default values in the methods and force users to be explicit (they do not need this function to set default value... and the day Turbo changes its default value it would be a real mess). |
Hi to you both :), Thank you for your feedback. I added the PHPDocs. and updated CHANGELOG.
These tags are generally used together. Turbo Rails and Turbo Laravel also use this third function. # https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/drive_helper.rb
# turbo_refreshes_with(method: :morph, scroll: :preserve)
def turbo_refreshes_with(method: :replace, scroll: :reset)
provide :head, turbo_refresh_method_tag(method)
provide :head, turbo_refresh_scroll_tag(scroll)
end
For Morphing, Turbo says the default is These default values are also found in Turbo Rails:
# https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/drive_helper.rb
# Configure method to perform page refreshes. See +turbo_refreshes_with+.
def turbo_refresh_method_tag(method = :replace)
raise ArgumentError, "Invalid refresh option '#{method}'" unless method.in?(%i[ replace morph ])
tag.meta(name: "turbo-refresh-method", content: method)
end
# Configure scroll strategy for page refreshes. See +turbo_refreshes_with+.
def turbo_refresh_scroll_tag(scroll = :reset)
raise ArgumentError, "Invalid scroll option '#{scroll}'" unless scroll.in?(%i[ reset preserve ])
tag.meta(name: "turbo-refresh-scroll", content: scroll)
end |
Works for me then, thanks! |
I put a few words ( |
That's perfect, thanks! |
meta
tags
I added 3 new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Can you squash/rebase your PR and fix issues found by DoctorRST please?
Status: Needs work |
33f594d
to
52c619e
Compare
52c619e
to
14dcfa6
Compare
I have squash and fix issues found by DoctorRST. |
Thanks @seb-jean. |
Hi,
I added Twig extensions for
meta
tags:turbo_exempts_page_from_cache
turbo_exempts_page_from_preview
turbo_page_requires_reload
turbo_refreshes_with
turbo_refresh_method
turbo_refresh_scroll