polyester
(Paul Roeland)
February 14, 2016, 2:36am
1
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}
</p>
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?
vangheem
(Nathan Van Gheem)
February 14, 2016, 5:23am
2
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:
<script>
require([
'mockup-patterns-moment'
]);
</script>
Second way(customize the plone bundle TTW):
Go to Site Setup -> Resource Registries
Go to overrides tab
Click "Add file" button, give it a name and put these contents in:
require([
'mockup-patterns-moment'
]);
go back to registry tab
click "Add Resource" and add the info for the file you just created and click save
click the plone bundle and add you resource to the list of resources
build the bundle
1 Like
vangheem
(Nathan Van Gheem)
February 14, 2016, 5:26am
3
Actually a better second option would be to add your own custom bundle TTW instead of customizing the plone bundle. Both work though.
seanupton
(Sean Upton)
February 15, 2016, 8:42pm
5
In either case, do you end up shipping moment to the browser twice across two bundles?
Sean
vangheem
(Nathan Van Gheem)
February 15, 2016, 10:03pm
6
vangheem
(Nathan Van Gheem)
February 16, 2016, 5:03pm
7
I take it back, it will not be loaded twice when logged in.
seanupton
(Sean Upton)
February 16, 2016, 6:11pm
8
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?
Sean
vangheem
(Nathan Van Gheem)
February 16, 2016, 6:31pm
9
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
vangheem
(Nathan Van Gheem)
February 16, 2016, 6:32pm
10
Here is the PR to include moment on the default plone bundle: https://github.com/plone/Products.CMFPlone/pull/1388
mgraf
(Michael)
July 4, 2016, 8:22am
11
Sorry for reactivate this post, but I still have problems to get 'moment.js' running
I have tried this
plone
insert code in main.js (diazo bundled) or
directly in theme.html
require([
'mockup-patterns-moment'
], 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
polyester
(Paul Roeland)
July 4, 2016, 8:46am
12
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
https://github.com/polyester/plonetheme.rfd16/blob/master/src/plonetheme/rfd16/theme/index.html line 68