lightncandy
lightncandy copied to clipboard
Possible to access parsed variables?
This is possibly a feature request but hopefully it's already possible.
Given a template
<div>
<p>{{#x}}{{value}}{{/x}}</p>
<p>{{msg-foo}}</p>
</div>
Is there a method that can parse the template to predict the keys it uses?
E.g. in this case such a function would return.
['msg-foo', 'x']
My use cases are
- throw an error when certain variables are passed to the template renderer e.g. if i dont pass a key foo to the template it should throw an error
- i want to programmatically define template variables. For example any template key prefixed with
msg-would be substituted beforehand e.g.
$templateData =[];
foreach($keysPrefixedWithMsg as $key){
$templateData[$key] = generateDataValue($key):
}
Let me know if I am not explaining well!
Thanks in advance!