Lack of interest List of variables *used* in a Template

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

Shadab

Well-known member
I'd love to see a feature (in debug mode only) that would allow developers to check which variables are *used* when rendering a template. This would come in very handy when we want to reuse default xenforo templates in our own applications; so we can easily know the bare minimum data (parameters) required to render a template.

For example, here's a list which could be generated for the "post" template:
Code:
$canReply
$canViewIp
$post
$post.attachments
$post.canCleanSpam
$post.canDelete
$post.canEdit
$post.canInlineMod
$post.canLike
$post.ip_id
$post.like_date
$post.position
$post.post_date
$post.post_id
$post.username
$thread
$visitor.user_id

I know it's almost impossible to list all the variables required for rendering a template; when you take into account template helpers, hooks and nested templates. But listing the immediate variable usage (nested templates not included) would still be nice. :)
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Thanks Jake. (I had even liked the post!)

A lot of times, the variables that a particular template *uses* is actually a small subset of variables *available* to it. Checking the controller which injects the variable parameters, or dumping the data gives us the variable's availability. But the only way to know if that variable is used is to check the template itself; which can be a bit tedious in case of large templates like thread_view & its associated templates.
 
We are fairly judicious in our exposure of variables to templates. I would take it that if a variable is exposed via $viewParams in the responseView(), it is required by the template named, or that we intend for it to be used in the future.
 
Top Bottom