summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-26 10:32:19 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-26 10:32:19 +0100
commitdecd8dbdc50c41be2c3394019ece146e4ccfb507 (patch)
tree22a41f988a885584453abb3aec304a277715811d /README.md
parentedc954f2ac0b13e13de68a686221e883747a9b7f (diff)
downloadgitbook-decd8dbdc50c41be2c3394019ece146e4ccfb507.zip
gitbook-decd8dbdc50c41be2c3394019ece146e4ccfb507.tar.gz
gitbook-decd8dbdc50c41be2c3394019ece146e4ccfb507.tar.bz2
Add infos in readme about variables and templating
Diffstat (limited to 'README.md')
-rw-r--r--README.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9b600cc..04c77e1 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,40 @@ With it's definition, this can contain bold text and all other kinds of inline m
#### Variables and Templating
+A set of variables can be defined in the `book.json`:
+
+```js
+{
+ "variables": {
+ "host": "mybook.com"
+ }
+}
+```
+
+These variables can be used in the markdown files:
+
+```
+The host is {{ book.host }}
+```
+
+You can also use condition with these variables:
+
+```
+{% if book.host == "mybook.com" %}
+
+{% else %}
+
+{% endif %}
+```
+
+Variables of `book.json` are available in the `book` namespace. You can also access informations about the `file` itself and the `gitbook` version:
+
+```
+My file is {{ file.path }}
+Modified at {{ file.mtime }}
+Book built with GitBook {{ gitbook.version }}
+```
+
#### Content References
You can use "content references," or conrefs, when writing books or documentation using GitBook.