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 know similar questions have been asked before, but I was just wondering if anything more solid has been implemented yet for getting these values from a given template.
For example, say I grab template X.html from a folder that contains the values {{FirstName}} and {{LastName}}. Is there a way of grabbing the variable names of each of those items regardless of the template chosen? That way I can compare that incoming data in form of say a Dictionary<string, string> and ensure it has a matching key-value pair for each of the values in the template.
I was wondering if I could do something like this for validation purposes ie make sure that a document has certain/all values filled.
Following this post I could do FluidTemplate.Statements but wasn't sure where to go from there (like how to filter the tags for example)
The text was updated successfully, but these errors were encountered:
I would require a visitor patter in Fluid to be able to go over anything that is parsed and extract all identifiers. You could build a simpler parser though that would only read {{ value }} statements. But it can be more complex with loops, conditions, ... which also use properties from the model.
Parlot which is the underlying parser exposes an event when a sub-element is analyzed. But I am not sure it exposes an event when a node is actually found, probably because it could discard it later on when there is an ambiguity that will then be resolved.
In the meantime, I would suggest to go over each statement, then check for the types you want to handle, recursively, and finally detect indentifiers (look for IdentifierSegment in MemberExpression objects).
I know similar questions have been asked before, but I was just wondering if anything more solid has been implemented yet for getting these values from a given template.
For example, say I grab template X.html from a folder that contains the values {{FirstName}} and {{LastName}}. Is there a way of grabbing the variable names of each of those items regardless of the template chosen? That way I can compare that incoming data in form of say a Dictionary<string, string> and ensure it has a matching key-value pair for each of the values in the template.
I was wondering if I could do something like this for validation purposes ie make sure that a document has certain/all values filled.
Following this post I could do FluidTemplate.Statements but wasn't sure where to go from there (like how to filter the tags for example)
The text was updated successfully, but these errors were encountered: