-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
Custom EntitiesTwigTwig template processingTwig template processingenhancementNew feature or requestNew feature or requestmetadataMeta(l) dataMeta(l) data
Milestone
Description
What?
When a render array output is generated via a metadata display template, e.g. {{ data.ia_an_array_dont_uoutput_me }}, the error (see screenshot below) is not reported in the preview.
Todo:
- Add a report of the KEYS used in the template v/s the JSON (basically a coverage of their use of values (from the source) in the output).
- Get all keys on the selected ADO
- Check their type (single value, iterable)
- Rename them to data.thekeyname in a function
- Parse the Twig checking how many times thekeyname is mentioned or attribute(‘thekeyname’, data) and in which lines
See for reference (no longer working due to changed interface):
format_strawberryfield/src/Entity/MetadataDisplayEntity.php
Lines 435 to 459 in 2e5cc2a
| private function getTwigVariableNames(ModuleNode $nodes): array { | |
| $variables = []; | |
| foreach ($nodes as $node) { | |
| if ($node instanceof \Twig_Node_Expression_Name) { | |
| $name = $node->getAttribute('name'); | |
| $variables[$name] = $name; | |
| } | |
| elseif ($node instanceof \Twig_Node_Expression_Constant && $nodes instanceof \Twig_Node_Expression_GetAttr) { | |
| $value = $node->getAttribute('value'); | |
| if (!empty($value) && is_string($value)) { | |
| $variables[$value] = $value; | |
| } | |
| } | |
| elseif ($node instanceof \Twig_Node_Expression_GetAttr) { | |
| $path = implode('.', $this->getTwigVariableNames($node)); | |
| if (!empty($path)) { | |
| $variables[$path] = $path; | |
| } | |
| } | |
| elseif ($node instanceof \Twig_Node) { | |
| $variables += $this->getTwigVariableNames($node); | |
| } | |
| } | |
| return $variables; | |
| } |
Metadata
Metadata
Assignees
Labels
Custom EntitiesTwigTwig template processingTwig template processingenhancementNew feature or requestNew feature or requestmetadataMeta(l) dataMeta(l) data
