I'm experienced with .NET MVC and wanting to learn a Python framework. I chose Pyramid.
.NET MVC has the concept of a master page, views and partial views. A master page would look something like:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
</head>
<body>
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</body>
</html>
I can then create a view that would fill in the space identified by MainContent
in the master page.
Going through the Pyramid wiki tutorial here, I see the author has repeated much of the same content in each of his templates--content that would normally be defined in a master page--and totally violated DRY.
Is there a concept of a master page in Pyramid?
Just like MVC.NET Pyramid can use any number of templating languages - and almost all of them support concepts similar to master pages. None of them call them that though ;-)
Chameleon is probably the most far out there - the tools that you use to define slots in master pages
ContentPlaceholder
, etc.) are calledmacros
in Chameleon and referred to by the rather heavy acronymMETAL
(Macro Expansion Template Attribute Language).In Jinja2 and Mako they are called
blocks
and Breve calls themslots
.Here is what a master page might look like in each of them:
Chameleon:
Jinja2:
Mako:
Breve: