Loading only the required context variables for a template
63 views
Skip to first unread message
Dungeon Hunter
unread,
May 14, 2016, 2:23:11 AM5/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pebble Templating Engine
Hi Team,
We have started using Pebble as a template engine for one of our portals in our product. When this product is used by the customer he also might modify the existing templates/add new. We have many context variables (around 40) which our UI developers use them while writing the templates.Currently we are blindly populating all such variables & putting them in the context. Instead we are looking for a way to extract the information from the PebbleTemplate to see what are the top level context variables have been used in the template. Based on this information we can inject the required context variables & gain some performance as well. I have looked at the source code & seems like implmenting a NodeVisitorFactory can allow us to access the complete nodes parsed. Our question is which nodes (e.g ContextVariableExpression Node) we should look for to populate the list of top level context variables used.
Your help is greatly appreciated.
Thanks.
Dungeon Hunter
unread,
May 15, 2016, 4:21:02 AM5/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pebble Templating Engine
Hi Team,
I have written a node Visitor to collect the required context variables from the template. But one problem i have been facing is when we are parsing the child templates only the variables used in the child templates are getting visited when we call gettemplate & not able to get the variables used in the parent template. Seems like the parsing of extended template happens only during the evaluation. I think it is because the extended template value can be variable as well. I think now i have no way to solve this.
Thanks.
Dungeon Hunter
unread,
May 15, 2016, 4:30:51 AM5/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pebble Templating Engine
I think it will be Good to provide some callback mechanism such as if the variable is not found in the context developer custom code should be given a chance to populate that variable & give it to the template evaluation code.