|
|
@@ -0,0 +1,91 @@ |
|
|
|
=== |
|
|
|
title: Auto Extend Plugin |
|
|
|
subtitle: type less, think more |
|
|
|
created: 2011-01-28 17:19:03 |
|
|
|
=== |
|
|
|
{% extends "doc.j2" %} |
|
|
|
|
|
|
|
===doc=== |
|
|
|
|
|
|
|
§§ blurb |
|
|
|
|
|
|
|
Hyde is built with the goal of separating content from presentation as |
|
|
|
much as possible without losing the power of template inheritance. It is |
|
|
|
a hard balancing act and auto extend is one big step on the wire. |
|
|
|
|
|
|
|
§§ /blurb |
|
|
|
|
|
|
|
## Extend |
|
|
|
|
|
|
|
The auto extend plugin relies on the metadata plugin for its configuration. |
|
|
|
You can specify an `extends` property in your metadata to let the plugin |
|
|
|
know the base template for that page. The plugin will automatically emit an |
|
|
|
`{%raw%}{% extends %}{%endraw%}` statement in the output. |
|
|
|
|
|
|
|
The following two configurations are equivalent. |
|
|
|
|
|
|
|
~~~~~jinja~~~~ |
|
|
|
{% raw %} |
|
|
|
{% extends "base.html" %} |
|
|
|
<!-- hello.html --> |
|
|
|
{% block content %} |
|
|
|
Hello World! |
|
|
|
{% endblock %} |
|
|
|
{% endraw %} |
|
|
|
~~~~~~~~~~~~~~~ |
|
|
|
|
|
|
|
~~~~~jinja~~~~ |
|
|
|
{% raw %} |
|
|
|
=== |
|
|
|
extends: base.html |
|
|
|
=== |
|
|
|
<!-- hello.html --> |
|
|
|
{% block content %} |
|
|
|
Hello World! |
|
|
|
{% endblock %} |
|
|
|
{% endraw %} |
|
|
|
~~~~~~~~~~~~~~~ |
|
|
|
|
|
|
|
## Default blocks |
|
|
|
|
|
|
|
It gets even better. The auto extend plugin also allows you to specify |
|
|
|
the default block so that you can take out another wrapping curly brace. |
|
|
|
|
|
|
|
The following snippet is equivalent to the above ones: |
|
|
|
|
|
|
|
|
|
|
|
~~~~~jinja~~~~ |
|
|
|
=== |
|
|
|
extends: base.html |
|
|
|
default_block: content |
|
|
|
=== |
|
|
|
<!-- hello.html --> |
|
|
|
Hello World! |
|
|
|
~~~~~~~~~~~~~~~ |
|
|
|
|
|
|
|
As you can see, this makes the page _layout free_. |
|
|
|
|
|
|
|
|
|
|
|
## Inheritance |
|
|
|
|
|
|
|
In combination with metadata inheritance, this plugin can completely |
|
|
|
eliminate redundancy on many sites. |
|
|
|
|
|
|
|
Given the following configuration, the output would be same as what |
|
|
|
is generated by any of the above snippets. |
|
|
|
|
|
|
|
~~~yaml~~~ |
|
|
|
site_name: Hello World #site.yaml |
|
|
|
meta: |
|
|
|
extends: base.html |
|
|
|
default_block: content |
|
|
|
~~~~~~~~~ |
|
|
|
|
|
|
|
~~~jinja~~~ |
|
|
|
<!-- hello.html --> |
|
|
|
Hello World |
|
|
|
~~~~~~~~~~~ |
|
|
|
|
|
|
|
Just Content! |
|
|
|
|
|
|
|
===/doc=== |