templates and controllers
    Thomas De Schampheleire 
    patrickdepinguin at gmail.com
       
    Sun Feb 15 15:45:14 EST 2015
    
    
  
On Sun, Feb 15, 2015 at 6:03 PM, Mads Kiilerich <mads at kiilerich.com> wrote:
> On 02/13/2015 09:34 PM, Thomas De Schampheleire wrote:
>>
>> For this static implementation, where one template file 'includes' the
>> other, there are also two variants used:
>> - render the included template from the controller, store it in a variable
>> that is passed in the controller context, and display the variable from the
>> main template.
>
>
> I don't think that is a good idea. I don't think pattern it is used that
> much? It is not so MVC-ish.
A quick search reveils:
$ grep -rn '= render' controllers/
controllers/followers.py:56:        c.followers_data =
render('/followers/followers_data.html')
controllers/forks.py:126:        c.forks_data = render('/forks/forks_data.html')
controllers/pullrequests.py:207:        c.pullrequest_data =
render('/pullrequests/pullrequest_data.html')
controllers/summary.py:111:                        readme_data =
renderer.render(readme.content,
controllers/admin/gists.py:234:        rendered =
render('admin/gists/edit.html')
controllers/admin/admin.py:144:        c.log_data =
render('admin/admin_log.html')
controllers/journal.py:210:        c.journal_data =
render('journal/journal_data.html')
controllers/journal.py:353:        c.journal_data =
render('journal/journal_data.html')
Unless you see a good reason why the above is like that, this could be
cleaned up...
>
>> - or let the main template include the other template directly from mako
>> code.
>
>
> +1
> I think it is better to handle all templating in the templates.
And let the controller just call 'render' once, for the 'main'
template to use, right?
Thanks,
Thomas
    
    
More information about the kallithea-general
mailing list