Commit Graph

75 Commits

Author SHA1 Message Date
pantor
4e909475ea at function for objects 2021-06-09 22:26:07 +02:00
Bryce Adelstein Lelbach aka wash
798a0b92b1 Add support for setting subobjects via JSON pointer in set statements. (#202)
E.g. `{% set x.y = 1 %}` sets the `y` member of `x` to 1.
2021-06-09 21:39:16 +02:00
pantor
d9ad8d195b whitespace control for comments 2021-06-09 21:33:47 +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
Wim Leflere
b4b9d8dc16 Fix build warnings for Clang and MSVC (#197)
* remove unnecessary semicolons on function definitions

* add virtual destructor to base class

* fix possible loss of data warning for double to int conversion with explicit cast

* ignore Visual Studio build folder

Co-authored-by: Wim Leflere <wleflere@cochlear.com>
2021-05-20 12:40:57 +02:00
Chinmay Garde
2491980b23 Fix inclusion in translation units with exceptions disabled. (#196)
If exceptions are disabled via `-fno-exceptions` or `INJA_NOEXCEPTION`, the use
of try-catch is disallowed by the compiler.

This patch makes does two things:
* Gates the use of try-catch in one translation unit on the definition of
  `INJA_NOEXCEPTION`.
* Make it such that translation units compiled with `-fno-exceptions` but no
  `INJA_NOEXCEPTION` implicitly sets `INJA_NOEXCEPTION`.

In the specific case of `ifstream::open`, setting the exceptions bits without
exceptions enabled should trip an assertion just like INJA_ABORT. The nice
message will not be present however, but that is absent when using INJA_ABORT as
well.

After this patch, inja can be successfully included without issue.
2021-05-19 19:53:55 +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
a3b0b41d48 allow variables starting with $ and @ 2021-01-16 16:40:03 +01:00
pantor
316567898e add size check in get_argument_vector 2021-01-16 15:38:14 +01:00
Tindy X
dacf8e8959 Suppress "missing initializer" warnings (#169)
* Suppress "missing initializer" warnings

* Try to fix build error on some platforms

* Add constructor for FunctionData

* Make Codacy happy
2020-08-26 20:09:24 +02:00
pantor
be5f4dd310 Consume byte order mark 2020-08-12 20:10:17 +02:00
Tindy X
ed58da75a6 Add whitespace control for expression (#162)
* Add whitespace control for expression

* Fix Environment::set_expression not working properly
2020-08-12 19:51:41 +02:00
SuperFish
918aa2a10d Uninitiated current_loop_data bug fix in render_to (#165)
* uninitiated current_loop_data bug fix in render_to

* change json_loop_data to  json_additional_data

* forgot to update single_include
2020-08-12 19:49:14 +02:00
pantor
5f9d429a6a add void callbacks 2020-08-10 19:38:12 +02:00
pantor
0b7d3d67cf perfomance improvements for printing integers 2020-08-09 23:02:25 +02:00
pantor
4182c5dfa9 constantify 2020-08-08 13:59:35 +02:00
pantor
73c04e6995 fix codacy issues II 2020-08-08 13:41:16 +02:00
pantor
52a73410de fix codacy issues 2020-08-08 13:36:26 +02:00
pantor
a570837703 remove iostream header, update year 2020-08-08 11:14:49 +02:00
pantor
a138be46b6 remove try/catch from truthy 2020-08-05 19:52:55 +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
pantor
6d46bf6fbf performance improvements for loops 2020-08-03 21:09:46 +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
02394683b1 fix single include 2020-07-26 13:16:45 +02:00
pantor
7529f21e63 dont copy strings into textnodes 2020-07-26 13:13:05 +02:00
pantor
59b446b215 Merge branch 'master' of https://github.com/pantor/inja 2020-07-26 12:52:40 +02:00
pantor
c56cbd63e9 add atid operation 2020-07-26 12:52:36 +02:00
Tindy X
38002d2e42 Using another method for exists call (#152) 2020-07-25 21:49:17 +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
390db9f2b7 improve count variables 2020-06-27 17:21:45 +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
0398edd419 code cleaning 2020-06-27 15:22:43 +02:00
pantor
fc5ab40da0 remove polyfill 2020-06-25 23:48:31 +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