{namespace jh = Heilmann\JhPhotoswipe\ViewHelpers} var openPhotoSwipe{data.uid} = function() { var pswpElement = document.querySelectorAll('.pswp')[0]; var items = [ , ]; // define options var options = { }; var gallery{data.uid} = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); gallery{data.uid}.init(); }; document.getElementById('jh-photoswipe-{data.uid}').onclick = openPhotoSwipe{data.uid};