Thanks to both of you for your informative answers, I believe I'm beginning to grasp how things are connected now.
Just to see if I understand things properly:
A Freemarker template cannot directly access the repository model objects and methods, so I would need to add js to do that. So, the proper way would be to create a web script, consisting of a js-file (typically a .get.js) that could access the repository, then create a model in the js-file, and use a freemarker template for presentation of the model. This web script could then be deployed in Share.
Is this correct, or am I still misunderstanding something?
Where are custom web scripts supposed to be placed in the Share filesystem? Is the folder structure site-webscripts/org/alfresco/ reserved for Alfresco provided web scripts?