Skip to content
Alexander Söderberg edited this page Nov 10, 2017 · 2 revisions

Templates

Kvantum supports JTwig templates by default.

Configure

In .kvantum/config/server.yml edit

templates:
  engine: !!com.github.intellectualsites.kvantum.api.config.CoreConfig$TemplatingEngine 'JTwig'

Configure views

It is possible to render JTwig templates using the built in views. It is recommended to use either the HTML or Standard view when dealing with JTwig.

Caching

It is required to explicitly turn off caching for the view when rendering JTwig templates. It is still possible to allow for file caching, however. This means that the template is stored in the cache, whilst the response isn't (as it is pseudo-dynamic). This can be done by adding a view option:

cacheApplicable: false

extensionRewrite

It is possible to match .html requests to .twig using the extensionRewrite view option. This is useful when using the default view, and allowing for the extension variable. An example of this is:

extensionRewrite:
  html: twig

filePattern

It is also possible to direct request to .twig files directly, by using a filePattern:

filePattern: ${file}.twig

Examples:

HTML View

views:
  index:
    filter: '[file=index].html'
    options:
      filePattern: ${file}.twig
      folder: ./public
      cacheApplicable: false
    type: html

Standard View

views:
  std:
    filter: '[file=index].[extension=html]'
    options:
      filePattern: ${file}.${extension}
      folder: ./public
      excludeExtensions:
      - txt
      extensionRewrite:
        html: twig
    type: std

Navigation

Templates

Configuration

Files can be found in .kvantum/config

Views

/commands

Development

Clone this wiki locally