Creating templates for views and viewlets

I've been working on Improving bobtemplates.plone and plonecli.
I've created templates that render simple views and viewlets. As I'm relatively new to the Plone development community, I may not be aware of the guidelines and the intricate details that have to be kept in mind while creating views or viewlets. As such, the views and viewlets rendered by the templates, reflect their most basic forms (as can be seen in the Mastering Plone Development Training Docs).

I would really appreciate it if some of the more experienced members of the community could review my work and suggest changes to improve the templates. :slight_smile:

The templates can be found on my fork of the bobtemplate.plone repository.
I have also created a gist explaining the various files and code snippets the view template renders. I'll also share a similar gist for viewlets in a couple of days.

Thank you!

1 Like

What you could do is open a pull request but indicate that it is 'work in progress' by prepending 'WIP: ' to the title of your new pull request. Then you can ask for a review from (probably) @MrTango

Great work already! Thanks for jumping in so quickly.

Alright, will do! Thank you! :slight_smile:

Here is the link to the gist explaining the viewlet rendering template.

I've opened the pull request.
It can be found here.

I made the templates by referring to the template for rendering content_type.
I found that many snippets of the code from content_type.py can be reused for making any new subtemplate, so I’ve added those as functions in the file base.py and have used these functions in view.py and viewlet.py (the file containing logic for the pre-render and post-render hooks of the respective templates).
I haven’t changed the contents of content_type.py to use these functions though.

@MrTango @tkimnguyen feedback on this would also be appreciated :smile:

Great what you have done so far.

Without knowing too much about this:

A quick look at the code (without trying it, yet): it looks to me that the views / viewlets will be added to every instance on the Zope.
I think you need to add a layer, maybe like this:

Thanks for the work so far

1 Like

Alright, I'll look into BrowserLayer's and make the required changes!
Thank you! :slight_smile:

1 Like