diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-24 23:02:00 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-24 23:02:00 +0100 |
commit | 0b592dd5c601d9225fdb6c395dc742e44e25504b (patch) | |
tree | f78e6fec2f84251fb7d73c50261e6b130d528f74 /docs | |
parent | addf6ade9ae594f6c5ab8bf112f5237459550c53 (diff) | |
download | gitbook-0b592dd5c601d9225fdb6c395dc742e44e25504b.zip gitbook-0b592dd5c601d9225fdb6c395dc742e44e25504b.tar.gz gitbook-0b592dd5c601d9225fdb6c395dc742e44e25504b.tar.bz2 |
Add doc about languages
Diffstat (limited to 'docs')
-rw-r--r-- | docs/SUMMARY.md | 2 | ||||
-rw-r--r-- | docs/languages.md | 9 | ||||
-rw-r--r-- | docs/templating.md | 30 |
3 files changed, 38 insertions, 3 deletions
diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index c653e63..71f9e68 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -10,7 +10,7 @@ * [Directory structure](structure.md) * [Pages and Summary](pages.md) * [Glossary](lexicon.md) -* [Multi-Lingual](langs.md) +* [Multi-Lingual](languages.md) * [Configuration](config.md) ### Miscellaneous diff --git a/docs/languages.md b/docs/languages.md new file mode 100644 index 0000000..9acead0 --- /dev/null +++ b/docs/languages.md @@ -0,0 +1,9 @@ +# Multi-Languages + +GitBook supports building books written in multiple languages. Each language should be a sub-directory following the normal GitBook format, and a file named `LANGS.md` should be present at the root of the repository with the following format: + +```markdown +* [English](en/) +* [French](fr/) +* [EspaƱol](es/) +``` diff --git a/docs/templating.md b/docs/templating.md index 0c0f5af..c3ab084 100644 --- a/docs/templating.md +++ b/docs/templating.md @@ -1,8 +1,34 @@ # Templating -GitBook uses the Nunjucks templating language to process pages and templates. +GitBook uses the Nunjucks templating language to process pages and theme's templates. -The Nunjucks syntax is very similar to Jinja2 and Liquid. +The Nunjucks syntax is very similar to **Jinja2** or **Liquid**. +### Variables +A variable looks up a value from the template context. If you wanted to simply display a variable, you would do: +``` +{{ username }} +``` + +This looks up username from the context and displays it. Variable names can have dots in them which lookup properties, just like javascript. You can also use the square bracket syntax. + +``` +{{ foo.bar }} +{{ foo["bar"] }} +``` + +If a value is undefined, nothing is displayed. The following all output nothing if foo is undefined: `{{ foo }}`, `{{ foo.bar }}`, `{{ foo.bar.baz }}`. + +### Filters + +Filters are essentially functions that can be applied to variables. They are called with a pipe operator (`|`) and can take arguments. + +``` +{{ foo | title }} +{{ foo | join(",") }} +{{ foo | replace("foo", "bar") | capitalize }} +``` + +The third example shows how you can chain filters. It would display "Bar", by first replacing "foo" with "bar" and then capitalizing it. |