You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the amazing Fluid functionality as part of my Orchard Core app. For testing purposes, when my app starts, I allow unsafe access just to ensure I have no security issues while I'm just trying to get template rendering working.
TemplateOptions.Default.MemberAccessStrategy = new UnsafeMemberAccessStrategy();
I create a new content item and store it in a variable "contentItem" and execute the following:
var fluidParser = new FluidParser();
var context = new TemplateContext(contentItem);
var template = fluidParser.Parse(THE_TEMPLATE_TEXT);
var result = await template.RenderAsync(context);
I can use all kinds values for the template text, such as:
It let's me get the year, month, or day the content item was published as well as its author. Excellent! At this point, I thought I was golden and could access anything under Content per the docs at https://docs.orchardcore.net/en/main/reference/modules/Liquid/#content-property For example, I have a "NodePart" with a "Text" property attached to contentItem so thought I could access that Text property via the "Content" object like this:
results in result = "System.Text.Json.Dynamic.JsonDynamicObject"
Interestingly, if I pause execution and use intellisense to look at the value, contentItem's Content property has a "Node" item under it with a Text property with the expected value I'm trying to get. And, if I just use:
I get the value I expect as that content item's "NodePart" has a handler that sets the content item's display text to the value of NodePart.Text.
Shouldn't I be able to use the above {{ Content.Node.Text }} template text to get NodePart.Text? It feels like I'm doing exactly what the docs say but it isn't working so it seems like a bug but maybe I'm just missing something...
Orchard Core version
2.1.6
The text was updated successfully, but these errors were encountered:
I'm trying to use the amazing Fluid functionality as part of my Orchard Core app. For testing purposes, when my app starts, I allow unsafe access just to ensure I have no security issues while I'm just trying to get template rendering working.
TemplateOptions.Default.MemberAccessStrategy = new UnsafeMemberAccessStrategy();
I create a new content item and store it in a variable "contentItem" and execute the following:
I can use all kinds values for the template text, such as:
It let's me get the year, month, or day the content item was published as well as its author. Excellent! At this point, I thought I was golden and could access anything under Content per the docs at https://docs.orchardcore.net/en/main/reference/modules/Liquid/#content-property For example, I have a "NodePart" with a "Text" property attached to contentItem so thought I could access that Text property via the "Content" object like this:
I also tried this out of curiosity:
but both end up wtih result = ""
The "Content" object itself returns something...
results in result = "System.Text.Json.Dynamic.JsonDynamicObject"
Interestingly, if I pause execution and use intellisense to look at the value, contentItem's Content property has a "Node" item under it with a Text property with the expected value I'm trying to get. And, if I just use:
template = fluidParser.Parse(@"{{ DisplayText }}");
I get the value I expect as that content item's "NodePart" has a handler that sets the content item's display text to the value of NodePart.Text.
Shouldn't I be able to use the above {{ Content.Node.Text }} template text to get NodePart.Text? It feels like I'm doing exactly what the docs say but it isn't working so it seems like a bug but maybe I'm just missing something...
Orchard Core version
2.1.6
The text was updated successfully, but these errors were encountered: