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
This took forever to figure out, so I'm hoping this issue can be a launching point for writing some documentation on a painful edge case I ran into when trying to build & debug a new shortcode extension. The TLDR is a docs that says something like this "for code running inside shortcode handler functions, to output debug information you should either return the log information as part of the shortcode handler return value, or you should use the grav log. Usage of the grav debugger will work in most situations, but log information will not be displayed inside the admin plugin"
Here's why (The following issue assumes all caching is turned off, so every request should re-trigger processing....)
When using the editor (at /admin/pages/<page route>) you are by default in the "Editor" mode. When you switch into the "Preview" mode, you can see the end result of your custom shortcode handler logic. However, if you have Grav debugger statements inside your shortcode handler function, they will not be displayed in the page's debugger log
The problem is that clicking "Preview" triggers a "processMarkdown" AJAX call to awaken grav and handle processing the markdown and by extension calling shortcode-core which will call your custom shortcode handler logic. Processed content will be returned via the same AJAX call via the magic of the admin plugin, but the debugger log contents are not returned.
On a different note, I went down this rabbit hole of debugging because my shortcodes work fine on /admin/preview/... but do not work on /admin/pages/.... It currently seems some high level information is different between those two, e.g. the $page variable changes.
The text was updated successfully, but these errors were encountered:
This took forever to figure out, so I'm hoping this issue can be a launching point for writing some documentation on a painful edge case I ran into when trying to build & debug a new shortcode extension. The TLDR is a docs that says something like this "for code running inside shortcode handler functions, to output debug information you should either return the log information as part of the shortcode handler return value, or you should use the grav log. Usage of the grav debugger will work in most situations, but log information will not be displayed inside the admin plugin"
Here's why (The following issue assumes all caching is turned off, so every request should re-trigger processing....)
When using the editor (at
/admin/pages/<page route>
) you are by default in the "Editor" mode. When you switch into the "Preview" mode, you can see the end result of your custom shortcode handler logic. However, if you have Grav debugger statements inside your shortcode handler function, they will not be displayed in the page's debugger logThe problem is that clicking "Preview" triggers a "processMarkdown" AJAX call to awaken grav and handle processing the markdown and by extension calling shortcode-core which will call your custom shortcode handler logic. Processed content will be returned via the same AJAX call via the magic of the admin plugin, but the debugger log contents are not returned.
On a different note, I went down this rabbit hole of debugging because my shortcodes work fine on
/admin/preview/...
but do not work on/admin/pages/...
. It currently seems some high level information is different between those two, e.g. the $page variable changes.The text was updated successfully, but these errors were encountered: