Commit Graph

133 Commits

Author SHA1 Message Date
pantor
a570837703 remove iostream header, update year 2020-08-08 11:14:49 +02:00
pantor
23e768403e add test for nested functions 2020-08-04 23:27:46 +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
pantor
f31378edaa slight changes 2020-07-13 21:17:59 +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
59d1d6b577 update benchmark 2020-07-13 14:36:30 +02:00
Lars Berscheid
db4356b345 add tests for get source location function 2020-06-30 09:25:02 +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
dadbb856cd add config throw_missing_includes, search_in_files 2020-06-27 17:47:58 +02:00
pantor
bc020a5ee0 add count variables to template 2020-06-27 17:18:25 +02:00
pantor
d25a4de54f show location for render errors 2020-06-27 17:05:56 +02:00
pantor
10b8ccccbc restructure third party modules 2020-06-25 22:57:37 +02:00
pantor
5cc3e30b66 add clang-format 2020-06-16 18:53:41 +02:00
craigpepper
c85f9a3837 Performance improvement for large data (#146)
* move to json v3.8.0

* Use loop context instead of copying input data

Co-authored-by: Craig Pepper <craig.a.pepper@boeing.com>
2020-06-16 18:47:06 +02:00
craigpepper
9533ba5240 Loop vars for object loops (#145)
* loops vars for object loops

* Fix formatting

Co-authored-by: Craig Pepper <craig.a.pepper@boeing.com>
2020-06-15 20:50:52 +02:00
pantor
93b307b079 add throw test for complete file 2020-03-21 15:00:39 +01: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
pantor
62d8593e6c move unit tests to doctest 2020-03-18 13:41:11 +01:00
Tom
8e6a8428fa Undo PIMPL pattern in Environment (#127)
* resync single_include

* Undo PIMPL pattern in Environment

* Environment now supports copy construction and assignment
* Add test for copying Environment

Closes #126
2019-11-22 11:12:28 +01:00
pantor
258def7bf0 little bit more code style 2019-09-14 12:28:55 +02:00
pantor
fe2ef9ce4e fix tab/spaces 2019-09-14 12:11:53 +02:00
pantor
a6a61586a4 code style (cpplint) 2019-09-14 12:05:51 +02:00
Tom
057075b110 retain scope when including a template (#118)
* apply documentation changes to single_include

* retain scope when including a template

* Use data from current scope when rendering an included template.
  This allows included templates to access loop variables, which
  was not possible before.
* Add test
2019-09-14 11:35:06 +02:00
pantor
d25937a85b add test and readme 2019-09-08 16:19:50 +02:00
Tom
419c93c840 Throw exception if a file cannot be opened, fix travis-ci builds (#117)
* throw exception if a file cannot be opened

* Add a new function in utils.hpp: open_file_or_throw: This function
  returns an opened std::ifstream or throws by calling `inja_throw`.
* Use this function in Parser::load_file which previously returned an
  empty string if the file couldn't be opened.
* Use this function in Environment::load_json which previously threw
  a `nlohmann::detail::parse_error` if the file couldn't be opened.
* In Parser::parse_statement: When including files through `include`,
  do not attempt to (re-)parse templates from files that were already
  included. Additionally, this prevents inja from attempting to load
  in-memory templates by their name from disk.
* Add tests that check if an exception is thrown when attempting to
  open files that do not exist.

* cmake: enable C++11

* cmake: require C++11 when depending on single_inja

* code style
2019-09-08 15:05:01 +02:00
pantor
d5532ac26a add at function 2019-04-07 16:15:12 +02:00
pantor
6698e98ea3 calculate length of strings with length function 2019-04-07 13:27:43 +02:00
Mark Hollomon
da5bbb1482 Remove unneed linking in update_loop_data (#85)
Commit a5862a0 made the linking step in update_loop_data unecessary
because the loop's copy of the data was made to come from the parent
loop's data rather than the original client's data.

While at it, also add one more nested loop test case.
2019-01-27 19:35:27 +01:00
Mark Hollomon
1dfd86fa6f Fix for issue #80 (#81)
* Fix for issue #80

When updating the `opening_chars`, line_statment was forgotten. So, a
change to any of the openers would cause line statements to start being
unrecognized.

I added a unit test to cover this case.

* fix indentation

* add update to single_include
2019-01-23 19:18:47 +01:00
pantor
dbcd5265fc add string_view polyfill 2019-01-21 21:34:34 +01:00
Lars Berscheid
a9d4ca9a4e fix string view reference movement in bytecode 2019-01-07 16:41:16 +01:00
pantor
699c207c8c Inja v2 (#67)
* inja2

* header only

* reduce dependencies

* code cleaning

* c++17

* use stdc++

* code cleaning

* infrastructure

* header only

* add infrastructure

* fix tests

* use minimum clang 6

* code cleaning, polyfill for c++11

* fix some file tests

* fix readme

* update appveyor

* fix polyfill and ci

* fix polyfill

* fix ci?

* test msvc __cplusplus

* add doxygen

* activate all tests

* code cleaning

* add coveralls, set default to dot notation

* add html test

* add doxygen comments

* test single_include file

* change build folder in appveyor

* correct make arguments in appveyor

* fix appveyor arguments
2018-12-23 16:13:15 +01:00
pantor
d90f93fda0 optional benchmark 2018-12-14 19:31:40 +01:00
pantor
595076ebec split dev files and amalgamate into a single header 2018-12-14 18:03:45 +01:00
pantor
0f1f57a8a3 fix cmake build for benchmark 2018-11-23 17:57:05 +01:00
pantor
7dbdd44b0e add benchmark, add hayai 2018-11-21 21:29:36 +01:00
pantor
b66f2d23aa add type checks: isString, ... 2018-11-11 14:34:35 +01:00
pantor
65cc971e21 Merge branch 'master' of https://github.com/pantor/inja 2018-08-29 19:31:55 +02:00
pantor
a496ec9585 update to json 3.2 and catch 2.3, clean cmake 2018-08-29 19:31:37 +02:00
Tian Jin
4eaeb2b182 Update CMakeLists.txt (#59) 2018-07-27 13:35:47 +02:00
Tian Jin
a06207b64b Update CMakeLists.txt (#58) 2018-07-25 07:44:54 +02:00
pantor
0898b1c302 use loop object for loop variables 2018-05-22 22:52:55 +02:00
pantor
71cfb21e61 include nlohmann/json in inja directly 2018-05-15 20:23:09 +02:00
pantor
cb18e2cd0c add in-memory includes via include_template 2018-05-14 20:21:29 +02:00
Samuel Leweke
1cb6b15cca Add exists() function that checks existence of key (#38)
* Add exists() function that checks existence of key

Adds an exists() function that checks whether a given key exists in the
data. If only one argument is provided to exists(), the global data is
queried for the item. If two arguments are given, the first argument
specifies the object to query for the key given as second argument.

Also adds corresponding unit tests and updates README for
documentation.

* Split exists() into exists() and existsIn()

Splits the exists() function, which previously took both one or two
arguments, into an exists() function accepting one and an existsIn()
function accepting two arguments.
2018-04-02 15:54:00 +02:00