Skip to content

Commit 10b8ccc

Browse files
committed
restructure third party modules
1 parent 5cc3e30 commit 10b8ccc

27 files changed

+17
-17
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Language: Cpp
2+
Language: Cpp
33

44
BasedOnStyle: LLVM
55
ColumnLimit: 120

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
Inja is a template engine for modern C++, loosely inspired by [jinja](http://jinja.pocoo.org) for python. It has an easy and yet powerful template syntax with all variables, loops, conditions, includes, callbacks, comments you need, nested and combined as you like. Inja uses the wonderful [json](https://github.com/nlohmann/json) library by nlohmann for data input and handling. Most importantly, *inja* needs only two header files, which is (nearly) as trivial as integration in C++ can get. Of course, everything is tested on all relevant compilers. Here is what it looks like:
3131

32-
```c++
32+
```.cpp
3333
json data;
3434
data["name"] = "world";
3535

@@ -40,7 +40,7 @@ inja::render("Hello {{ name }}!", data); // Returns "Hello world!"
4040
4141
Inja is a headers only library, which can be downloaded from the [releases](https://github.com/pantor/inja/releases) or directly from the `include/` or `single_include/` folder. Inja uses `nlohmann/json.hpp` as its single dependency, so make sure it can be included from `inja.hpp`. json can be downloaded [here](https://github.com/nlohmann/json/releases). Then integration is as easy as:
4242
43-
```c++
43+
```.cpp
4444
#include <inja.hpp>
4545
4646
// Just for convenience
@@ -67,7 +67,7 @@ This tutorial will give you an idea how to use inja. It will explain the most im
6767

6868
The basic template rendering takes a template as a `std::string` and a `json` object for all data. It returns the rendered template as an `std::string`.
6969

70-
```c++
70+
```.cpp
7171
json data;
7272
data["name"] = "world";
7373

@@ -76,7 +76,7 @@ render_to(std::cout, "Hello {{ name }}!", data); // Prints "Hello world!"
7676
```
7777
7878
For more advanced usage, an environment is recommended.
79-
```c++
79+
```.cpp
8080
Environment env;
8181
8282
// Render a string with json data
@@ -99,7 +99,7 @@ env.write_with_json_file("./templates/greeting.txt", "./data.json", "./result.tx
9999
```
100100

101101
The environment class can be configured to your needs.
102-
```c++
102+
```.cpp
103103
// With default settings
104104
Environment env_default;
105105

@@ -123,7 +123,7 @@ env.set_line_statement("##"); // Line statements ## (just an opener)
123123
### Variables
124124
125125
Variables are rendered within the `{{ ... }}` expressions.
126-
```c++
126+
```.cpp
127127
json data;
128128
data["neighbour"] = "Peter";
129129
data["guests"] = {"Jeff", "Tom", "Patrick"};
@@ -145,7 +145,7 @@ Statements can be written either with the `{% ... %}` syntax or the `##` syntax
145145

146146
#### Loops
147147

148-
```c++
148+
```.cpp
149149
// Combining loops and line statements
150150
render(R"(Guest List:
151151
## for guest in guests
@@ -162,7 +162,7 @@ In a loop, the special variables `loop/index (number)`, `loop/index1 (number)`,
162162
#### Conditions
163163
164164
Conditions support the typical if, else if and else statements. Following conditions are for example possible:
165-
```c++
165+
```.cpp
166166
// Standard comparisons with variable
167167
render("{% if time.hour >= 20 %}…{% else if time.hour >= 18 %}…{% endif %}", data); // True
168168
@@ -179,7 +179,7 @@ render("{% if not guest_count %}…{% endif %}", data); // True
179179
#### Includes
180180

181181
You can either include other template files or already parsed templates.
182-
```c++
182+
```.cpp
183183
// Other template files are included relative from the current file location
184184
render("{% include \"footer.html\" %}", data);
185185

@@ -192,7 +192,7 @@ env.render("Content: {% include \"content\" %}", data); // "Content: Hello Peter
192192
### Functions
193193
194194
A few functions are implemented within the inja template syntax. They can be called with
195-
```c++
195+
```.cpp
196196
// Upper and lower function, for string cases
197197
render("Hello {{ upper(neighbour) }}!", data); // "Hello PETER!"
198198
render("Hello {{ lower(neighbour) }}!", data); // "Hello peter!"
@@ -249,7 +249,7 @@ render("{{ isArray(guests) }}", data); // "true"
249249

250250
In the default configuration, no whitespace is removed while rendering the file. To support a more readable template style, you can configure the environment to control whitespaces before and after a statement automatically. While enabling `set_trim_blocks` removes the first newline after a statement, `set_lstrip_blocks` strips tabs and spaces from the beginning of a line to the start of a block.
251251

252-
```c++
252+
```.cpp
253253
Environment env;
254254
env.set_trim_blocks(true);
255255
env.set_lstrip_blocks(true);
@@ -260,7 +260,7 @@ With both `trim_blocks` and `lstrip_blocks` enabled, you can put statements on t
260260
### Callbacks
261261

262262
You can create your own and more complex functions with callbacks.
263-
```c++
263+
```.cpp
264264
Environment env;
265265

266266
/*
@@ -288,7 +288,7 @@ env.render("{{ double-greetings }}", data); // "Hello Hello!"
288288
### Comments
289289

290290
Comments can be written with the `{# ... #}` syntax.
291-
```c++
291+
```.cpp
292292
render("Hello{# Todo #}!", data); // "Hello!"
293293
```
294294

include/inja/token.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace inja {
1111

1212
/*!
13-
* \brief Helper-class for the inja Parser.
13+
* \brief Helper-class for the inja Lexer.
1414
*/
1515
struct Token {
1616
enum class Kind {

scripts/update_single_include.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ SOURCE_ROOT=$(dirname "${DIR}")
66
echo "Move to Source Root: ${SOURCE_ROOT}"
77
cd ${SOURCE_ROOT}
88

9-
python3 amalgamate/amalgamate.py -c amalgamate/config.json -s include -v yes
9+
python3 third_party/amalgamate/amalgamate.py -c scripts/amalgamate_config.json -s include -v yes

single_include/inja/inja.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ struct JsonError : public InjaError {
18221822
namespace inja {
18231823

18241824
/*!
1825-
* \brief Helper-class for the inja Parser.
1825+
* \brief Helper-class for the inja Lexer.
18261826
*/
18271827
struct Token {
18281828
enum class Kind {
File renamed without changes.

0 commit comments

Comments
 (0)