aboutsummaryrefslogtreecommitdiffstats
path: root/man/blogc-template.7.ronn
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-03 03:25:12 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-03 03:25:12 +0200
commit9acb03e669e20180b9bc95ca02b21460761fef87 (patch)
tree376d2c46c207daaf5b6c1939c805e4191f02a036 /man/blogc-template.7.ronn
parent82995655dca72297155c5632029284dacbcccc87 (diff)
downloadblogc-9acb03e669e20180b9bc95ca02b21460761fef87.tar.gz
blogc-9acb03e669e20180b9bc95ca02b21460761fef87.tar.bz2
blogc-9acb03e669e20180b9bc95ca02b21460761fef87.zip
template-parser: renderer: implemented 'else' support in templates
yeah, this is stupid. after more than 320 commits and 26 releases, we finally support the 'else' statement in the template engine. I don't know if I'm dumb or what, but it took me that long to find a "simple" solution to this basic issue. yep, no more `{% ifdef FOO %}...{% endif %}{% ifndef FOO %}...{% endif %}` blocks. but seriously, who cares?! :/
Diffstat (limited to 'man/blogc-template.7.ronn')
-rw-r--r--man/blogc-template.7.ronn14
1 files changed, 11 insertions, 3 deletions
diff --git a/man/blogc-template.7.ronn b/man/blogc-template.7.ronn
index 3499d7c..1fdc479 100644
--- a/man/blogc-template.7.ronn
+++ b/man/blogc-template.7.ronn
@@ -143,7 +143,8 @@ based on the value and existence of variables in the current scope.
The implementation of conditionals is simple, and each will just evaluate the
value of a single variable.
-The available conditionals are: `ifdef`, `ifndef` and `if`.
+The available conditionals are: `ifdef`, `ifndef` and `if`. `else` statements
+are supported.
### ifdef conditional
@@ -154,9 +155,12 @@ This is how an `ifdef` conditional is defined in a template:
{% ifdef TITLE %}
This is title: {{ TITLE }}
+ {% else %}
+ Untitled entry
{% endif %}
-In this case, if the `TITLE` variable is defined, the content is included.
+In this case, if the `TITLE` variable is defined, the content after the statement
+is included. Otherwise, the content after `else` statement is included.
### ifndef conditional
@@ -170,6 +174,8 @@ This is how an `ifndef` conditional is defined in a template:
{% endif %}
In this case, if the `TITLE` variable is not defined, the content is included.
+`else` statements are supported here, even if it does not makes much sense to
+be used this way.
### if conditional
@@ -184,7 +190,9 @@ comparisions are strcmp(3)-like.
This is how an `if` conditional is defined in a template:
{% if TITLE == "My Title" %}
- Title is "My Title"
+ Special description of "My Title"
+ {% else %}
+ Title is {{ TITLE }}
{% endif %}
Or: