Commit Graph

58 Commits

Author SHA1 Message Date
Vladislav Nawrocki
ea845eee91 Add pipe syntax support for function calls like in Jinja2, resolves #294 (#296) 2025-10-18 05:35:57 -07:00
pantor
804823dbca filesystem::path fixes 2025-03-31 22:54:04 +02:00
pantor
9b6587135c move to std::filesystem 2025-03-31 22:45:01 +02:00
Florian Sattler
34514c2658 Prevent local stack memory leakage when parsing (#302)
We need to resets current_block to a nullptr after parsing the template
in `parse_into`, otherwise, current_block will refer to local stack
space after we return from Parser::parse.
2025-03-18 20:20:34 -05:00
Florian Sattler
808c3711d0 Removes unnecessary template content copy (#301)
By taking the template content by value and moving into the local
member, we can prevent and additional copy of 'content' when creating a
Template.
2025-03-18 20:20:02 -05:00
Vladislav Navrocky
384a6bef3f Fix: Remove circular dependencies in headers (#295)
* Remove circular dependencies in headers

* Fix unit test includes and test data directory location
2025-02-11 09:03:42 +01:00
Matheus Werny
92994bec0a clang-tidy applied and CMake installation of the single header added (#287)
* Fixed headers and linter marks applied

Headers were wrong.
Applied some linter suggestions. There are still many left.

* CMake adjusted for single header

CMake can now install the single header.
Removed an unneeded header.

---------

Co-authored-by: Berscheid <1885260+pantor@users.noreply.github.com>
2024-10-05 09:36:11 +02:00
pantor
3e0c30f27f static load file 2023-09-03 16:26:32 +02:00
Kubo Takehiro
d462b9f829 Fix issue 246 (#247)
* Add `parse_expression` with one argument in preparation to fix #246.

* Fix issue #246: `func(n1 + n2, n3)` runs as if `func(n1, n2 + n3)`

* Simplify parser for an expression enclosed by parentheses.
2022-12-04 11:28:04 +01:00
pantor
edc17798b3 Merge branch 'master' of github.com:pantor/inja 2022-07-10 13:46:36 +02:00
pantor
9f923b3677 add check for too few arguments in operator parser 2022-07-10 13:46:33 +02:00
Mihai Stan
17a59c0b78 fix warnings with VS2019, W4, c++20 (#230)
* fix warnings with VS2019, W4, c++20

* update single include

Co-authored-by: Berscheid <1885260+pantor@users.noreply.github.com>
Co-authored-by: pantor <lars.berscheid@online.de>
2022-06-20 12:06:28 +02:00
pantor
771e47f6da fix search directory for string templates 2022-06-20 11:43:45 +02:00
pantor
eb04bfc7d3 clang-format 2021-11-12 08:35:56 +01:00
pantor
81cfa140e4 init LiteralNode with string view, code cleaning 2021-11-12 08:13:42 +01:00
pantor
2da715a12a parse_filename without json 2021-11-12 08:06:56 +01:00
pantor
623c267383 make_result and code cleaning 2021-11-11 22:05:21 +01:00
pantor
120691339d rename json -> data 2021-11-10 12:53:27 +01:00
pantor
2239e231bc remove string view polyfill 2021-11-10 12:14:54 +01:00
pantor
cf71b54151 add include callback 2021-09-07 10:00:33 +02:00
pantor
12a2c9bbf2 unify json data type 2021-09-01 16:40:43 +02:00
pantor
99b85d69e7 remove headers in files, add central header 2021-07-25 14:24:49 +02:00
pantor
8d65633b6a add warnings for clang and fix them 2021-06-17 19:48:28 +02:00
pantor
95af782ca2 Add Child Inheritance Feature (#198)
* add block and extend feature

* constify, code cleaning

* update single include

* add html language to readme

* clean tests

* constantify, update year
2021-05-25 10:18:21 +02:00
pantor
eac2162629 fix include of in-memory templates 2021-05-17 20:44:32 +02:00
pantor
389c1d64f0 short circuit evaluation 2021-05-17 19:57:33 +02:00
pantor
9d59943220 add INJA_NOEXCEPTION 2021-01-16 18:06:43 +01:00
pantor
52a73410de fix codacy issues 2020-08-08 13:36:26 +02:00
pantor
23e768403e add test for nested functions 2020-08-04 23:27:46 +02:00
DeiRex75
222fc960be Fix nested function (#159)
* switched order in token::kind::id of function and operator behavior

* add tests

* fixed nested function order

* created single include

Co-authored-by: pantor <lars.berscheid@online.de>
2020-08-04 23:20:37 +02:00
pantor
b141129bda fix segmentation fault 2020-08-04 23:19:55 +02:00
pantor
0f38867cb0 further performance improvements 2020-08-04 22:42:59 +02:00
pantor
889da4da4f add set statements 2020-08-03 21:29:05 +02:00
DeiRex75
44c473538b Switched order in token::kind::id of function and operator behavior (#155)
* switched order in token::kind::id of function and operator behavior

* add tests

Co-authored-by: pantor <lars.berscheid@online.de>
2020-08-02 19:01:38 +02:00
pantor
7529f21e63 dont copy strings into textnodes 2020-07-26 13:13:05 +02:00
pantor
c56cbd63e9 add atid operation 2020-07-26 12:52:36 +02:00
pantor
f4731061db fix strings in test, make more methods private 2020-07-15 20:51:00 +02:00
Rafael Lorenzo Alonso
17175f70da Making it compatible with gcc 4.8 (#150)
There is an inline function that assumes the compiler has copy elision
optimization which is actually not required until C++17. GCC 4.8 does it
but it requires the copy constructor to be defined which is not the case
for std::ifstream. Fixed by passing reference by parameter.

Co-authored-by: Rafael Lorenzo Alonso <ralorenz@cisco.com>
2020-07-15 17:53:30 +02:00
pantor
6eb71dd3ea Rewarite core with an AST for statements and RPN for expressions (#149)
* test

* improve ast

* add if statement

* shunting-yard start

* renderer as node visitor

* improve ast

* improve ast further

* first functions

* improve ast v3

* improve ast v4

* fix parser error location

* nested ifs

* fix comma, activate more tests

* fix line statements

* fix some more tests

* fix callbacks without arguments

* add json literal array and object

* use switch in expression

* fix default function

* fix loop data

* improved tests and benchmark

* fix minus numbers

* improve all

* fix warnings, optimizations

* fix callbacks argument order

* dont move loop parent

* a few more test

* fix clang-3

* fix pointers

* clean

* update single include
2020-07-13 15:20:04 +02:00
Lars Berscheid
bb613e29ba fix render error position in templates 2020-06-30 08:51:13 +02:00
pantor
c4d99c9455 add finegrained whitespace control 2020-06-29 23:12:12 +02:00
pantor
d43d497f88 fix stringview in included templates 2020-06-27 22:06:13 +02:00
pantor
dadbb856cd add config throw_missing_includes, search_in_files 2020-06-27 17:47:58 +02:00
pantor
d25a4de54f show location for render errors 2020-06-27 17:05:56 +02:00
pantor
0398edd419 code cleaning 2020-06-27 15:22:43 +02:00
pantor
fc5ab40da0 remove polyfill 2020-06-25 23:48:31 +02:00
pantor
5cc3e30b66 add clang-format 2020-06-16 18:53:41 +02:00
sabelka
7ce19f9b61 Parser error position (#134)
* add function to get position of current token

* new exception parser_error with error location

* parser throws parser_error with error location

* update single include

* get error position in text

* bump to 2.3

* subclass exceptions

* update single include from every directory

* center badges in readme

* github ci windows, mac

* use default compiler

* check ci

* fix ci

* test ci

* fix ci

* fix ci

* test ci

* badges to github action

* add check for single include

* fix check

* check (should fail)

* fix all ci

* add artifact in single include ci

* update to newest nlohmann/json

* move unit tests to doctest

* move to json v3.6.1

* add function to get position of current token

* new exception parser_error with error location

* parser throws parser_error with error location

* update single include

* get error position in text

* bump to 2.3

* subclass exceptions

Co-authored-by: pantor <lars.berscheid@online.de>
2020-03-21 14:56:21 +01:00
Christof Krüger
3f071a2aac Fix warnings (VS2017 x64). (#133)
* Fix warnings (VS2017 x64).

* Update single_include/inja.hpp.
2020-01-27 22:52:43 +01:00
Dodzey
e7d5c5332d Static cast to avoid VS140 C4244 warning (#119) 2019-10-27 18:42:53 +01:00