How to make pat-moment available to anonymous users

I'm having some difficulty grasping how I can move certain (mockup) patterns from one preconfigured bundle to another.

In a template, I have something like

  <p class="pat-moment"   data-pat-moment="format:HH:mm dd DD MMMM YYYY">
    ${python: item_start}

which works perfectly well for logged-in users, but not anonymous. Is there an obvious way to have a specific pattern (in this case the pat-moment one) to be in the 'plone' bundle?

Well, that's a bummer. That should probably be part of the default bundle!

There are 2 ways to solve this.

First way(add js to your theme)

This can be in a file that you include or just inline at the bottom of your theme:


Second way(customize the plone bundle TTW):

  1. Go to Site Setup -> Resource Registries

  2. Go to overrides tab

  3. Click "Add file" button, give it a name and put these contents in:


  1. go back to registry tab
  2. click "Add Resource" and add the info for the file you just created and click save
  3. click the plone bundle and add you resource to the list of resources
  4. build the bundle
1 Like

Actually a better second option would be to add your own custom bundle TTW instead of customizing the plone bundle. Both work though.

In either case, do you end up shipping moment to the browser twice across two bundles?


Yes. However, if we do then it won't be...

I take it back, it will not be loaded twice when logged in.

Just to clarify, though, if an add-on that ships its own bundle, and one of the resources in that add-on's bundle has dependency on moment.js, it still (for AMD reasons) needs to ship moment (or any other thing shipped in plone bundle) twice/duplicatively to browser?


No. If you compile the js to include it, then it will of course. But if you build it with stubs for those resources or let it dynamically load, it'll notice it is already there and not load it again.

1 Like

Here is the PR to include moment on the default plone bundle:

Sorry for reactivate this post, but I still have problems to get 'moment.js' running

I have tried this

  • insert code in main.js (diazo bundled) or

  • directly in theme.html

      ], function(){
          console.log('hello world');

With this html
<span class="pat-moment" data-pat-moment="format:LL;">2016-07-15 00:00:00+02:00</span>
produces following output
2016-07-15 00:00:00+02:00

Is any working theme/example available?

Thank you

hi @mgraf, I put the requirement for pat-moment in the index.html of my diazo theme directly. Not the most elegant, but hey deadlines :wink: line 68