jinja2cpp / Jinja2Cpp

Jinja2 C++ (and for C++) almost full-conformance template engine implementation
https://jinja2cpp.github.io
Mozilla Public License 2.0
494 stars 84 forks source link

Render error when single quotation mark meets right curvly bracket #247

Open starrynight opened 6 months ago

starrynight commented 6 months ago

A single example like this will cause a render error ( tested on Release 1.3.1)

void minimum_example() {

    jinja2::Template tpl;

    tpl.Load("{{ 'Hello World!' + '\n'}}");

    std::cout << tpl.RenderAsString({}).value() << std::endl;

}

I found the issue could be avoided if a space is inserted:

tpl.Load("{{ 'Hello World!' + '\n' }}");

But considering template file is usually not so space sensitive and accurate, I wonder if this is something that can be fixed?

Wovchena commented 3 months ago

A possible workaround is to replace ' with \".