Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a layout is defined in the page frontmatter of a page it's loaded from the /layouts folder. If no layout is defined the default layout that is part of the component is loaded.
The layout supports any properties. Properties are defined in the frontmatter using YAML. All properties are accessible in the page templates using $[property]. Properties should be lowercase.
Loading
The layout is is a relative path and can include subfolders. Example
The layout follows the same naming conventions as the page, and is auto-discovered. The specific template engine is loaded based on the filename suffix.
File Naming
The file extension should be the layout format, suffixed with the template engine used to render the layout.
Properties
A layout can have frontmatter, the frontmatter becomes available as PHP variables in the layout. The 'page' variable is reserved and cannot be used in the frontmatter.
An additional $page variable is available which gives direct access to all the page properties, and is readable and writable.
See:h ttps://github.com//pull/6
Inheritance
When a layout specifies another layout, it means the content of the first layout will be injected into the ktml:content tag of the second layout. As an analogy, think of Russian dolls that fit into each other. Each layout fits into another layout that it specifies. See: https://jekyllrb.com/tutorials/convert-site-to-jekyll/#how-layouts-work
At the same time the frontmatter of the layouts will be merged, if an inner layout specifies the same variable as an outer layout, the outer layout will receive the value defined in the inner layout. This allows to use frontmatter to dynamically adjust the behavior of the outer layout.
Notes
As part of this change page template files no longer require to have a format suffix eg '.html'.
This PR allows makes it possible to use
<ktml:content>
in a layout to render the content of the page.As part of this change the module filter is now also available, this means that you can make use of the
<ktml:module position="[position]">[content]</ktml:module>
syntax to insert modules on the fly. The module filter should also be documented as it's very powerful. Code can be found here: koowa/template/filter/module.phpIt's now also possible to use import to import the content of none renderable files. Supported types are: html, css, js and svg. Example
<?= import'('path/to/image.svg) ?>