1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Closed Suggestions' started by Shadab, Dec 30, 2010.

  1. Shadab

    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:
    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. :)
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Shadab

    Shadab Well-Known Member

    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.
  4. Kier

    Kier XenForo Developer Staff Member

    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.

Share This Page