mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 02:23:30 +00:00
Add doc about languages
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user