-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Access root object from template #575
Comments
If you use the overload of If that doesn't answer your question I could use another more detailed example to understand what you are trying to do. But also I am not sure |
The idea is simply for debug purpose. I want to be able to display a json representation of the object passed to the model. I could create a custom filter but the issue is the same, I don't know what to apply the filter one. I know it would be easier to pass an object with a single property that actually contains my object but it would mean that I have to update all my templates to take that into account. Which I why I was wondering if it was possible to access the object somehow in the template. |
I understand that you are passing the model to TemplateContext now. You can't access it directly from the template. What you can do is "also" add it as a custom property by doing Also in case that could give you some ideas, in Orchard we created a custom filter that will dump an object into the javascript console, so we can see the object graph in the console of developer tools: |
I'm having this use case where I simply want to display a JSON representation of the object passed to the template.
I cannot pass an object with a Root property, I really have to pass the object itself.
I tried with "{{ context | json }}" or "{{ model | json }}" but nothing works.
So the question is "is it possible to access the root object from within the template ?".
Thanks :-)
The text was updated successfully, but these errors were encountered: