-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add dump template func for debugging #3957
Comments
I'd be in favor of a general |
That might be alright is user can specify what they want to be printed. Assuming that the template fn name is
I gave the above examples because I ended up creating something like PS: The |
I agree with @kaushalmodi and @moorereason we should be able to print whatever with it. It is just about presenting readable data to someone who knows what he is looking for. |
Or someone who does not know what he is looking for finds something that looks interesting and starts using it and one of two things happens
|
Everybody is already using printf to do just that. (I didn't need a dump func to find about At least with your own dump function, you get to control what is printable and what is not. Would it be that hard to filter certain keys from the page context ? (chances are 90% of the time people will be dumping something from the page context) PS: I don't agree with the filtering, but if it's a middle ground, I'll take it. |
We have legacy history in Hugo with a liberal PR merge policy (with some additions' design looking sub-optimal in retrospect), exported fields/methods that should probably not been exported to the templates (AbsSourceFilename being one recent example; I should have spent the extra amount of work needed to hide it from the templates). We have once said something in the line of "we merge this now, and see how it works -- if we like it, we document it." That model breaks once people learn how to use So, this |
I don't know how it would be possible to prove this without testing it. Conversely I find it difficult to imagine a scenario where
but then stop and not use a variable because it wasn't formatted nicely. I imagine most would do something similar to what I did... a couple of annoying search and replace operations in my editor to add new lines after The obfuscation of the data didn't stop me from using the variable, it just made me wonder why it was so poorly formatted. |
There has unfortunately been some pushback with adding general debugging tools to Hugo gohugoio/hugo#4081 (comment) gohugoio/hugo#3957 (comment) I've found this can make things a lot more difficult than it needs to be. There appears to be a belief that adding debugging tools will lead to people using things that are undocumented. Unfortunately in my experience I've had trouble with values that are documented but where the documentation isn't very clear. Even where debugging tools are provided the output is minified and requests to change this have so far been rejected for the same reason as above. A user has developed a theme which can work around many of these issues and add a convenient debugging partial to allow you to clearly see the contents of most variables. (see README changes for more specifics.)
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
See https://github.com/sanity-io/litter
The output is great (as below from a random test), but may be "too much" even for the advanced user:
The text was updated successfully, but these errors were encountered: