Templater icon indicating copy to clipboard operation
Templater copied to clipboard

User script namepaces based on folder

Open pobk opened this issue 8 months ago • 1 comments

Is your feature request related to a problem? Please describe.

I have a number of scripts that are currently organised in subfolders in the custom scripts folder. However, Templater renders these in the API as entirely under the same namespace of tp.user.

Describe the solution you'd like

Perhaps adding an option to allow Templater to render folders under the scripts directory as a namespace/collection for scripts?

e.g. scripts/formvalues/ratingselect.js is made available as tp.user.formvalues.ratingselect()

Describe alternatives you've considered I'm not sure there are any alternates available here?

Additional context This is probably going to break backwards compatibility for others so this might need to be enabled in settings.

pobk avatar May 03 '25 10:05 pobk

You can always make your own namespaces by returning multiple functions from a single function, for example:

module.exports = function() {
  return {
    ratingselect: () => {
      // ...
    },
    // ...
  };
}
tp.user.formvalues().ratingselect()

Zachatoo avatar May 23 '25 04:05 Zachatoo

Closing this in favor of #1607 , these two are not compatible with each other.

Zachatoo avatar Aug 16 '25 21:08 Zachatoo