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.
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
Introduce HttpRequest & HttpContext Fluid values #16979
Introduce HttpRequest & HttpContext Fluid values #16979
Changes from 2 commits
e8cad86
dcf9df2
a1f1efa
e7bcaa7
6c17332
688c67c
6d6c37e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check failure on line 49 in src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs
GitHub Actions / Build & Test (ubuntu-latest)
Check failure on line 49 in src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs
GitHub Actions / Build & Test (ubuntu-latest)
Check failure on line 50 in src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs
GitHub Actions / Build & Test (ubuntu-latest)
Check failure on line 50 in src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs
GitHub Actions / Build & Test (ubuntu-latest)
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.
You can't cache the _context, it's specific to each request. Get a new value of the context every time this method is called. And don't wrap it in an ObjectValue
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.
If you want to cache the HttpContext in case the fluid value is used multiple times (not common I'd say, and for what gain). You could use the
TemplateContext
object which has a dictionary. And use a private constant to put it there. But again might be more work that benefits so I wouldn't advise that.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.
The question again, how ToXXXValue() will be evaluated or should we ignore it for this particular object?
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.
I fixed it. Now I understand your question. And now you have your answer.
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.
Technically we have to decide what to render when we do
{{ Request }}
. Here it's returning"Request"
, but we could decide to return the url (even if it's more costly) or something that is valuable. I am fine if you think""
is actually better in that case, or"(Request)"
if that helps users understand that it's an object.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.
I'm fine with your changes, I was struggling to display something useful if we render
{{ Request }}
but what you did is much simpler and doesn't require construction injectionThere 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.
We could add
Request
,User
.. etc and deprecate theRequest
object in a major releaseThere 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.
What about this one @sebastienros?