Skip to content

Commit 3c5c86a

Browse files
authored
Update basic.md
1 parent d3e638a commit 3c5c86a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/usage/basic.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline const char* AnimalsToString(Animals e)
3939
}
4040
```
4141
42-
Of course, you can write this producer in the way like [this](https://github.com/flexferrum/autoprogrammer/blob/87a9dc8ff61c7bdd30fede249757b71984e4b954/src/generators/enum2string_generator.cpp#L140). It's too complicated for writing 'from scratch'. Actually, there is a better and simpler way.
42+
Of course, you can write this producer like [this](https://github.com/flexferrum/autoprogrammer/blob/87a9dc8ff61c7bdd30fede249757b71984e4b954/src/generators/enum2string_generator.cpp#L140). It's too complicated to write 'from scratch'. But there is a better and simpler way.
4343
4444
Firstly, you should define the simple jinja2 template (in the C++ manner):
4545
{% raw %}
@@ -59,9 +59,9 @@ inline const char* {{enumName}}ToString({{enumName}} e)
5959
```
6060
{% endraw %}
6161

62-
This template is quite basic. Actually, this is the regular text mixed with blocks, which have special meaning. Template parts wrapped with {% raw %}'{{' and '}}'{% endraw %} are expressions. During the template rendering this expression will be evaluated and the result will be inserted into final text. For instance, `{% raw %}{{ enumName }}{% endraw %}` should be replaced with the value of `enumName` param (if any) or should be substituted with an empty string.
62+
This template is quite basic. Actually, this is the regular text mixed with blocks, which have special meaning. Template parts wrapped with {% raw %}'{{' and '}}'{% endraw %} are expressions. During the template rendering this expression will be evaluated and the result will be inserted into the final text. For instance, `{% raw %}{{ enumName }}{% endraw %}` should be replaced with the value of `enumName` param (if any) or substituted with an empty string.
6363

64-
Template parts wrapped in {% raw %}'{%' and '%}'{% endraw %} are "statements" or control blocks. Each of such statement has special meaning and different processing inside Jinja2C++ engine. For instance, `{% raw %}{% for item in items %}...{% endfor %}{% endraw %}` is a loop statement. `items` variable should be a collection and loop body will be inserted into the final text as many times as many items in `items`. The current item can be accessed inside loop body via `item` variable.
64+
Template parts wrapped in {% raw %}'{%' and '%}'{% endraw %} are "statements" or control blocks. Such statements have special meaning and different processing inside Jinja2C++ engine. For instance, `{% raw %}{% for item in items %}...{% endfor %}{% endraw %}` is a loop statement. `items` variable should be a collection and loop body will be inserted into the final text as many times as many items in `items`. The current item can be accessed inside loop the body via the `item` variable.
6565

6666
Template author can define new variables via `set` statement, test expressions via `if`, define macros via `macro`, include other templates via `include` and so on. There are many statements in the Jinja2 specification. But in order to be useful there should be a way to pass parameters to the template engine from the 'outside'. For instance, for the template above `items` should be somehow passed to the Jinja2C++ engine in order to be iterated. And there is a way to do it! Here it is!
6767

0 commit comments

Comments
 (0)