Add doc about languages

This commit is contained in:
Samy Pesse
2016-02-24 23:02:00 +01:00
parent addf6ade9a
commit 0b592dd5c6
3 changed files with 38 additions and 3 deletions
+1 -1
View File
@@ -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
+9
View File
@@ -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/)
```
+28 -2
View File
@@ -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.