Closed Mido-sys closed 3 years ago
This is great. I think i've had this issue as well. I don't know if its related but I had a similar issue recently. I think is with the result of a function call:
...
<p class="mr-2">Employees will be reminded on <date class="font-semibold"><%= period.EmployeeReviewReminderDate().Format("Jan 2, 2006") %></date>.</p>
...
I get
no prefix parse function for DOT found
Do you think is related ?
@paganotoni , yes we will need to add this feature to allow function chain calls. Shouldn't be too hard. I will send a new pull request for this feature.
Added #139 to keep track of this one. Thank you @Mido-sys
Give access to nested array/map structs. For example,
people[0].Name
orpeople[0].Children[0].Final
. The nested array/map access depth is unlimited.The pull request builds on the existing code that worked with nested structs up to an array. The existing code didn’t give access to the underlying array fields
people.Name.Chilldren[0]
issue#101Background:
The existing code processed the nested struct access by building a list of identifiers from back to front. So if the user wanted to access
robot.Avatar.Name
it will return anast.Identifier
with a nestedCallee
:When the compiler receives the
ast.Identifier
,evalIdentifier
checks first ifCallee
is not nil. If not, then it evaluates the expressionast.Callee
. The compiler will keep unwrapping theast.Identifier
till it reaches the condition ofast.Callee
isnil
. Ifast.Callee
isnil
then it will check if theast.Identifier.Value
stored in thectx
. As a result,ast.Identifier.Value = robot
value will return the object that was passed in thectx
. Since the keyrobot
is stored inctx
it will then return that object to the upper chain which now will access the object returned by the keyast.Identifier.Value = Avatar
using reflection thus will return the nested object till it bubbles up to the first Callee which again, will have access to the object returned byast.Identifier.Value: "Final"
.Restirctions of
evalIdentifier
:The function only processes objects returned by the Callee that are structs. It can’t process objects that return a slice. So if the process of robot returns a slice then Avatar won’t be able to access it. As a result, the existing code wasn't able to process struct fields that are of type map/array.