Feature: Support partial rendering#9
Open
alexander-nitsche wants to merge 6 commits intopsmb:masterfrom
Open
Conversation
With this patch, in addition to document nodes, you can also have content nodes (partials) re-rendered via AJAX requests. The identifier of the node is now stored in the cache entry along with the Fusion path and is thus available on request to render the partial.
A key feature of this package is to associate a partial with a unique partial key for later dedicated rendering in AJAX requests. The implementation strictly relied on a defined position of the responsible Psmb.Ajaxify:RenderPath within the Psmb.Ajaxify:Ajaxify Fusion object. With this patch, that relationship has been relaxed: the Psmb.Ajaxify:RenderPath Fusion object can now be used both standalone and nested within any depth of Psmb.Ajaxify:Ajaxify. However, when used standalone, it must be called at the first level of the partial - in the same way as Psmb.Ajaxify:Ajaxify.
Psmb.Ajaxify:Ajaxify and Psmb.Ajaxify:RenderPath can be assigned to the same generic property name in all occurrences for better code readability.
The partial key must be unique per Fusion path and content node. Therefore, the current state of one key per Fusion path is not sufficient. With this patch, the key will be a hash based on both attributes. The hash is generated automatically, thereby removing the requirement for the developer to manually specify a unique key. Because this patch changes the value of the publicly used URL parameter `&ajaxPathKey=<value>` this patch is marked as breaking.
Previously, partial rendering considered only the Fusion path. With the recent changes, both the Fusion path and the content node, called the partial context, are now considered. Consider this change in the naming conventions. In detail these are: - Public: Rename URL parameter "ajaxPathKey" to "ajaxPartialKey". - Public: Rename `Psmb.Ajaxify:RenderPath` to `Psmb.Ajaxify:PartialSerializer`. - Public: Rename `Psmb.Ajaxify:RenderPathResolver` to `Psmb.Ajaxify:PartialResolver`. - Public: Rename "[P]athsCache" to "[Pp]artialCache" cache identifier. - Private: Use FQDN for \Exception to satisfy the editor :). - Private: Use verbose common "fusionPath" over "path" and "renderPath". - Private: Rename "pathKey" to "partialKey". - Private: Even smaller adjustments .. Since this patch changes the naming of some public elements, it is marked as breaking. And breaking changes are included because there were other breaking changes in this patch already.
Apply PSR-2 and general Neos .editorconfig styles to the codebase to eliminate mixing of styles and facilitate future patching.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Dmitri,
@dlubitz and I recently wanted to use this package to render partials consisting of a Fusion object and a content node via AJAX. We didn't want to use the built-in Psmb.Ajaxify:Ajaxify, but instead retrieve the partial key and use that in our own AJAX implementation. Therefore, we added some features to this package to make it work, mainly:
and I made some final revisions and reformatting of the code to reflect and unify the new naming conventions and common Neos CMS code styles. I've broken these changes into their own commits for ease of review.
I marked two commits as breaking change because they changed some API names, even though the main Psmb.Ajaxify:Ajaxify access point remains unchanged. I think it would be useful to reflect these breaking changes in an increase to the major release version to inform users of the new naming conventions.
I followed the naming conventions of the Neos core packages as much as possible and tried to be backwards compatible with Neos 3.0 by comparing the code statements used with those of Neos Core 3.0. Finally, I tested the changes in a local Neos 7.3 instance, where they worked as expected.
No features were removed, only added.
Thank you very much for your work and greetings!
Alex