Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to access parsed variables? #345

Open
jdlrobson opened this issue May 29, 2020 · 0 comments
Open

Possible to access parsed variables? #345

jdlrobson opened this issue May 29, 2020 · 0 comments

Comments

@jdlrobson
Copy link

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

  1. 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
  2. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant