{% load demotags %}
{{ page }}
{% endverbatim %} variable is available:
* Writing: {% verbatim %}{{ page.name }}
{% endverbatim %} will produce: {{ page.name }}
* Writing: {% verbatim %} {{ page.last_modified }}
{% endverbatim %}
will produce: {{ page.last_modified }}
* Writing: {% verbatim %} {{ page.size|filesizeformat }}
{% endverbatim %}
will produce: {{ page.size|filesizeformat }}
Note how in this last case we also made use of the filesizeformat
builtin filter of Django.
Users may add more information even load a python module into the page.
More details on the {% link "context.html" %} page.
### Links and Images
Users can also make use of pyblue specific template tags that are
automatically available. For example the `link` tag generates
relative paths to any other file.
* {% verbatim %}{% link "context.html" %}
{% endverbatim %} will
produce the following: {% link "context.html" %}.
* {% verbatim %}{% link "context.html" text="Click me now!" %}
{% endverbatim %} will
produce the following: {% link "context.html" text="Click me now!" %}.
{% img css="right thumb" pattern="fractal4" %}
Important: Note how in this case the file is located in info/context.html
Yet we did not have
to put the full path the linking tag. `PyBlue` found the file and linked it properly.
Why did that work? The {% verbatim %}{% link "context.html" %}
{% endverbatim %}
command performs a regular expression search on all files in the directory and
once it finds a match it produces a link to it with the proper relative path.
This keeps links correct even if the files were to be moved later.
Note that the search string is a regular expression and it is sufficient
to specify the shortest unambiguous part of the filename. `PyBlue` will find it and link it.
> As a matter of fact this is one reason PyBlue was written. I got very tired of fixing
> broken links after a site reorganization. PlyBlue now does it automatically.
The {% verbatim %}{% img "fractal.png" %}
{% endverbatim %} tag works similarly to the link tag.
but generates image links. It also takes the `css` parameter where css classes may be passed
to the image. The CSS itself will have to be defined in the page header or the site asssets.
### Markdown
To include markdown content into an HTML document place it between
{% verbatim %}`{% markdown %}` and `{% endmarkdown %}`{% endverbatim %}
template tags.
### Fenced code blocks
When using markdown fenced codeblocks may be used. Include code between ``` symbols that can
also take language hints:
```python
import sys
for line in open("data.txt"):
print line.strip()[:10]
```
### Include code
To include syntax highlighted code from a file write {% verbatim %}{% code "context.py" lang="python" %}
{% endverbatim %}
{% code "context.py" lang="python" %}
This file is also special because of its name: `context.py`. The contents of
this python module is available inside every page under the name of `context`.
For example writing {% verbatim %}`{{ context.greeting }}`{% endverbatim %} produces: {{ context.greeting }}.
This is where the full power of `pyblue` shows. You see, you can go wild and add any and all
data that you might need. Call out to any program, read any file etc. It is `Python` all [the way down][turtles].
[turtles]: https://en.wikipedia.org/wiki/Turtles_all_the_way_down
### Include markdown
Alternatively one can instruct PyBlue to include the rendered content of markdown files.
To include the file `example.md` in its original content one would use
{% verbatim %}{% code "example.md" %}{% endverbatim %}
this would produce:
{% code "example.md" %}
This same file could be included as html with {% verbatim %}{% markdown_file "example.md" %}{% endverbatim %}
In that case it will produce the following:
{% markdown_file "example.md" %}
Note how in both cases an automatic search takes place PyBlue will find the location
of the file `example.md` wherever it might be on the root
directory. That's super convenient.
### Advanced templates
The [django templating][django_templates] system allows extending or including other templates or sections.
* {% verbatim %}{% extend "sometemplate.html" %}
{% endverbatim %}
* {% verbatim %}{% include "sometemplate.html" %}
{% endverbatim %}
These features support template inheritance and composition.
Read on from more {% link "advanced.html" %} and {% link 'mdtest.html' %}
### Licensing
* PyBlue uses the [MIT license][license].
* PyBlue is being developed by Istvan Albert see https://github.com/ialbert
* PyBlue has been inspired by [PyGreen][pygreen] created by Nicolas Vanhoren
see (https://github.com/nicolas-van/pygreen) but over the years it has diverged so much
that it probably does not use any code from that codebase.
[django]: https://www.djangoproject.com/
[markdown]: http://en.wikipedia.org/wiki/Markdown
[pygreen]: https://github.com/nicolas-van/pygreen
[license]: https://github.com/ialbert/pyblue/blob/master/LICENSE.txt
[bootstrap]: http://getbootstrap.com/
[django_templates]: https://docs.djangoproject.com/en/1.9/ref/templates/language/
{% endmarkdown %}