From 0b592dd5c601d9225fdb6c395dc742e44e25504b Mon Sep 17 00:00:00 2001 From: Samy Pesse Date: Wed, 24 Feb 2016 23:02:00 +0100 Subject: [PATCH] Add doc about languages --- docs/SUMMARY.md | 2 +- docs/languages.md | 9 +++++++++ docs/templating.md | 30 ++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 docs/languages.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index c653e63a6..71f9e6804 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 000000000..9acead0a9 --- /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 0c0f5afdf..c3ab084eb 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.