0

I'm very new at Pyramid, I have used Django in the past, but I can't find a clean explanation of how to use base templating in Pyramid Chameleon templates.

I have a very simple .pt file which I want to be my base.pt template it's something like this:

<link href="static/bootstrap/css/bootstrap.css" rel="stylesheet">
<head>
</head>
<body>

<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
  <div class="container">
    <div class="navbar-header">
      <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
      </button>
      <a href="#" class="navbar-brand">My project</a>
    </div>
  </div>
</header>

</body>
</html>

As you can see I try to have bootstrap header in all the following templates of my project, so what do I need to have so that all templates inherit or have base.pt as base template ? In Django I will just use {% include base.html %}

PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
  • 1
    Chameleon is one of 3 officially supported templating systems in Pyramid alongside Mako and Jinja2. Jinja2 is basically the same as Django's template syntax so perhaps you want to use pyramid_jinja2 in your projects. – Michael Merickel Aug 28 '13 at 16:44
  • @MichaelMerickel that is great news, I thought there was only Chamelean and Mako. – PepperoniPizza Aug 28 '13 at 17:35
  • @MichaelMerickel that is the kind of asnwer I was looking, if you could give it as an answer I will accept it: http://docs.pylonsproject.org/projects/pyramid_jinja2/en/latest/ – PepperoniPizza Aug 28 '13 at 17:54
  • No problem. I didn't put it as an answer earlier because you may have been legitimately trying to figure out Chameleon. – Michael Merickel Aug 28 '13 at 19:57

1 Answers1

1

Chameleon and Mako are the two templating languages with support currently bundled within Pyramid. However, Jinja2 is officially supported by the pyramid_jinja2 addon and is easily activated. Jinja2 provides a syntax very similar to Django's if you do not wish to learn Chameleon.

config.include('pyramid_jinja2')

@view_config(..., renderer='myapp:templates/home.jinja2')
def view(request):
    return {}
Michael Merickel
  • 23,153
  • 3
  • 54
  • 70