aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-21 15:42:16 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-21 15:42:16 -0300
commitfa016a15156bf8122b2d3dccaecca53f471d6ecb (patch)
tree12e8ec4c971455b7a1578fdb9c4eaf0e37f018c3 /README.md
parent8d8f508b859647461d1e9f13eeab647ceae54597 (diff)
downloadblogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.tar.gz
blogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.tar.bz2
blogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.zip
refactored blocks
- changed block names: - single_source -> entry - multiple_sources -> listing - multiple_sources_once -> listing_once - added -t cli option, to build listing pages, instead of guess it from the number of source files provided.
Diffstat (limited to 'README.md')
-rw-r--r--README.md40
1 files changed, 19 insertions, 21 deletions
diff --git a/README.md b/README.md
index 1fe0295..9043f92 100644
--- a/README.md
+++ b/README.md
@@ -11,26 +11,26 @@ The main idea is simple: a source file is read by the compiler, and a result fil
The source file must provide (almost) all the data needed to build the result file, including any variables. The result file is built using a template, that defines how the information provided by the source file should be used to generate a reasonable result file.
-The compiler will always generate a single file, no matter how many source files are provided. If more than one source file is provided, the template must know how to convert them to a single result file.
+The compiler will always generate a single file, no matter how many source files are provided. If more than one source file is provided, the compiler (and the template) must know how to convert them to a single result file.
The templates can define blocks. These are the block rules:
-- If something is defined outside of blocks, it should be always used.
-- If something is defined inside a block, it should only be used if the block matches the compiler argument expectations, e.g.:
- - ``single_source`` should be used if just one source file is provided.
- - ``multiple_sources`` should be used if more than one source file is provided, being used once for each source file.
- - ``multiple_sources_once`` should be used if more than one source file is provided, but only once.
+- If something is defined outside of blocks, its raw content should be always included.
+- If something is defined inside a block, it should only be included if the block matches the compiler argument expectations, e.g.:
+ - ``entry`` should be include if just one source file is provided.
+ - ``listing`` should be included if more than one source file is provided, being included once for each source file, if the compiler is called with ``-l``.
+ - ``listing_once`` should be inclueded if more than one source file is provided, but only once, if the compiler is called with ``-l``.
- Template blocks can be defined multiple times in the same template, but can't be nested.
The variables defined in the source file are only available inside of blocks. If something does not depends on the source files, and is global, it must be hardcoded in the template, for the sake of simplicity.
-The templates can use conditional statements: ``{% if variable %}`` and ``{% endif %}``. They check if a variable is defined or not. As variables are not available outside of blocks, these conditional statements can't be defined outside of blocks.
+The templates can use conditional statements: ``{% if variable %}`` and ``{% endif %}``. They check if a variable is defined or not. As variables are not available outside of blocks, these conditional statements can't be defined outside of blocks as well.
-Variables are not available in ``multiple_sources_once`` blocks, because it is not possible to guess which source file to get the variables from.
+Variables are not available in ``listing_once`` blocks, because it is not possible to guess which source file would provide the variable contents.
As the compiler is output-agnostic, Atom feeds and sitemaps should be generated using templates as well.
-The content won't touch the content. If the user write pre-formatted text it will stay formatted, and the user may want to enclose the ``{{ CONTENT }}`` statement with ``<pre>`` and ``</pre>`` tags in the templates. For more flexibility, the user can even write raw HTML in the source content.
+The compiler won't touch the content. If the user write pre-formatted text it will stay pre-formatted, and the user may want to enclose the ``{{ CONTENT }}`` statement with ``<pre>`` and ``</pre>`` tags in the templates. For more flexibility, the user can even write raw HTML in the source content.
The compiler is designed to be easily used with any POSIX-compatible implementation of ``make``.
@@ -39,20 +39,18 @@ The compiler is designed to be easily used with any POSIX-compatible implementat
```
TITLE: My nice post
-DATE: 2007-04-05T12:30-02:00
+DATE: 2007-04-05 12:30:00
----
test content.
more test content.
```
-If more than one source file is provided, they won't be sorted, and will be used by ``multiple_sources`` blocks in the order that they were provided in the command line.
-
-The ``DATE`` variable is an ISO-8601 date-time, with seconds, and always in UTC. If you want to show the date of your posts in your blog, you can use the ``DATE`` variable, but it won't be nicely formated, it will always be an ISO-8601 date-time.
+If more than one source file is provided to the compiler with the ``-t`` argument, they won't be sorted, and will be included by ``listing`` blocks in the order that they were provided in the command line.
Variables are single-line, and all the whitespace characters, including tabs, before the leading non-whitespace character and after the trailing non-whitespace character will be removed.
-Pre-formatted content is available in template blocks as the ``CONTENT`` variable.
+Raw content is available in template blocks as the ``CONTENT`` variable.
### Template file syntax
@@ -60,25 +58,25 @@ Pre-formatted content is available in template blocks as the ``CONTENT`` variabl
```html
<html>
<head>
- {% block single_source %}
+ {% block entry %}
<title>My cool blog >> {{ TITLE }}</title>
{% endblock %}
- {% block multiple_sources_once %}
+ {% block listing_once %}
<title>My cool blog - Main page</title>
{% endblock %}
</head>
<body>
<h1>My cool blog</h1>
- {% block single_source %}
+ {% block entry %}
<h2>{{ TITLE }}</h2>
{% if DATE %}<h4>Published in: {{ DATE }}</h4>{% endif %}
<pre>{{ CONTENT }}</pre>
{% endblock %}
- {% block multiple_sources_once %}<ul>{% endblock %}
- {% block multiple_sources %}<p><a href="{{ FILENAME }}.html">{{ TITLE }}</a>{% if DATE %} - {{ DATE }}{% endif %}</p>{% endblock %}
- {% block multiple_sources_once %}</ul>{% endblock %}
+ {% block listing_once %}<ul>{% endblock %}
+ {% block listing %}<p><a href="{{ FILENAME }}.html">{{ TITLE }}</a>{% if DATE %} - {{ DATE }}{% endif %}</p>{% endblock %}
+ {% block listing_once %}</ul>{% endblock %}
</body>
</html>
```
-This template would generate a list of posts, if multiple source files were provided, and single pages for each post, if only one source file was provided. The ``FILENAME`` variable is generated by the compiler, and is the source file name without its last extension.
+This template would generate a list of posts, if multiple source files were provided with ``-t``, and single pages for each post, if only one source file was provided. The ``FILENAME`` variable is generated by the compiler, and is the source file base name without its last extension.