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
The Prototype Kit includes a "Templates" page when run in development mode that allows the designer to create pages from templates exposed by plugins, or to view them before creating them.
In testing we observed designers using the View feature, but in our plugin viewing templates doesn't work. This is because macros defined in plugin code don't get exported to template viewing but they do in pages.
We can redefine some of our exported functions as pure macros, but not all of them due to limitations with Nunjucks. So we need to come up with some way to get functions loaded during template viewing (including possibly submitting a patch to the Prototype Kit).
The text was updated successfully, but these errors were encountered:
Currently we define these functions in the plugin for use in the prototype by passing in a reference to the prototype kit in our initialisation call. Unfortunately, the prototype kit seems designed for people to add functions within the prototype itself and not from plugins. Mentions of plugin config key nunjucksFunctions seem to load functions from the app's functions.js file, rather than the plugins.
The plugin does not currently have a dependency on the prototype kit, because we don't want the circular reference, making it impossible to add a function at the global level in the plugin unless the manage-plugin pages call our initialise function.
We might be able to extend the prototype kit to optionally locate/call a specific function to initialise the plugin, in much the same way that other plugin systems dlsym a function to return a structure of pointers to functions. We could discover a specific function signature and call it with config and reference to the library etc. Whether we can get this merged in a reasonable time-frame is another question.
Had a look at trying to wrap the main content in the templates with a check for the existence of a specific function, and it's fine, it hides the existing content. Unfortunately, if we have an else block to show some static content when previewing the page then:
It can't use any of the existing macros that use functions, (e.g. it's not just the path functions)
Any macros we used to provide static content would appear in the template when the template was installed (and would be broken)
It's also probably true that there'll be a problem if you install a template before you've added the initialisation code as the functions won't be available.
The Prototype Kit includes a "Templates" page when run in development mode that allows the designer to create pages from templates exposed by plugins, or to view them before creating them.
In testing we observed designers using the View feature, but in our plugin viewing templates doesn't work. This is because macros defined in plugin code don't get exported to template viewing but they do in pages.
We can redefine some of our exported functions as pure macros, but not all of them due to limitations with Nunjucks. So we need to come up with some way to get functions loaded during template viewing (including possibly submitting a patch to the Prototype Kit).
The text was updated successfully, but these errors were encountered: