Templating

Thane Thomson edited this page Feb 1, 2017 · 9 revisions

As of v0.16.0 of Statik, you can choose to either construct your templates using Jinja2 or Mustache, or a combination of the two (depending on whether or not you're running in safe mode).

Engine Specifics

For specific information on using either supported template engine, please see the following pages.

Configuration

Since it's possible to mix your templates, and there's the possibility of overlap between the two kinds of templates, Statik needs to know the precedence to give to each engine. To indicate this to Statik, make sure to include the templates configuration in your config.yml file. This is the default:

templates:
  providers:
    - jinja2
    - mustache

As such, if one of your views specifies a template called home, and you have a home.html.jinja2 and a home.html.mustache in your templates folder, it will give preference to home.html.jinja2.

If you want to force the template engine to only use a specific provider, you can simply do the following:

templates:
  providers:
    - mustache

This will force the engine to only support Mustache templates. This will allow you to simply call your template files, for example, "home.html" and the engine will assume they are Mustache templates. Similarly, for Jinja2-only support, only specify the jinja2 provider.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.