You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quite often I need to get a template from a user that can render my mandatory parameters and not use anything else. For example, an email template in an e-shop can only use predefined parameters, and anything extra will be rendered incorrectly (because the variable does not exist).
Latte could include a native way to see what all parameters the template implements (plus a list of keys in the array, if it's a $var['abcd'] notation for example). At the same time, there should be a check.
The implementation may use, for example, a native PHP interface where we scan for real typehints for methods, or at least an array of parameters from the user.
I know I can compile the Latte template to native PHP code, and then verify the connection with PhpStan, but this behavior is simply not possible to run on a production server where we receive a specific template from the user.
Thank you.
The text was updated successfully, but these errors were encountered:
I am not sure I understand your use case correctly but how about macro {parameters} - it defines what parameters can be used in template and everything else is undefined. So you can just prepend this macto to template code from user and try to render it.
Hello,
Quite often I need to get a template from a user that can render my mandatory parameters and not use anything else. For example, an email template in an e-shop can only use predefined parameters, and anything extra will be rendered incorrectly (because the variable does not exist).
Latte could include a native way to see what all parameters the template implements (plus a list of keys in the array, if it's a
$var['abcd']
notation for example). At the same time, there should be a check.The implementation may use, for example, a native PHP interface where we scan for real typehints for methods, or at least an array of parameters from the user.
I know I can compile the Latte template to native PHP code, and then verify the connection with PhpStan, but this behavior is simply not possible to run on a production server where we receive a specific template from the user.
Thank you.
The text was updated successfully, but these errors were encountered: