diff --git a/docs/en/docs/options.md b/docs/en/docs/options.md index 72a3160..6bd7706 100644 --- a/docs/en/docs/options.md +++ b/docs/en/docs/options.md @@ -1,4 +1,6 @@ -# Derive Options +# Configuration + +## Derive options You can control the rendering behaviour via `template` attribute. @@ -13,7 +15,7 @@ struct TemplateStruct { `template` attribute accepts the following options. - `path`: path to template file. This options is always required. -- `escape`: Enable HTML escaping (default: `false`) +- `escape`: Enable HTML escaping (default: `true`) - `delimiter`: Replace the '%' character used for the tag delimiter (default: '%') - `rm_whitespace`: try to strip whitespaces as much as possible without collapsing HTML structure (default: `false`). This option might not work correctly if your templates have inline `script` tag. @@ -28,3 +30,32 @@ struct TemplateStruct { ... } ``` + +## Configuration file + +Sailfish allows global and local configuration in a file named `sailfish.yml`. Sailfish looks for this file in same directory as `Cargo.toml` and all parent directories. +If, for example, `Cargo.toml` exists in `/foo/bar/baz` directory, then the following configuration files would be scanned in this order. + +- `/foo/bar/baz/sailfish.yml` +- `/foo/bar/sailfish.yml` +- `/foo/sailfish.yml` +- `/sailfish.yml` + +If a key is specified in multiple configuration files, the value in the deeper directory takes precedence over ancestor directories. + +If a key is specified in both configuration file and derive options, then the value specified in the derive options takes precedence over the configuration file. + +### Configuration file format + +Configuration files are written in the YAML 1.2 format. The default configuration is described below. + +``` +template_dir: "templates" +escape: true +delimiter: "%" + +optimization: + rm_whitespace: false +``` + +You can specify another template directory in `template_dir` option. Other options are same as derive options. diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index f556c47..7dab418 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -44,6 +44,6 @@ nav: - 'Welcome': 'index.md' - 'Installation': 'installation.md' - 'Getting Started': 'getting-started.md' - - 'Options': 'options.md' + - 'Configuration': 'options.md' - 'Syntax': - 'Overview': 'syntax/overview.md'