Giter Site home page Giter Site logo

grantlee's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grantlee's Issues

segfault when mixing inlcude and extend

I am trying to include template parts that itself use extend to generate their content. Most of the time this results in a segmentation fault, sometimes the rendering partly finishes without an error. I created an example application demonstrating my issue here: https://github.com/buschmann23/grantleetest

Maybe I am doing something completely wrong, or is this combination of include and extend not supported anyways? My Grantlee version is 5.1.0.

The gdb backtrace of of the sefault is as follows:

Program received signal SIGSEGV, Segmentation fault.
QList<QObject*>::QList (this=<optimized out>, l=..., this=<optimized out>, l=...) at /usr/include/qt5/QtCore/qlist.h:828
828         if (!d->ref.ref()) {
(gdb) bt
#0  QList<QObject*>::QList (this=<optimized out>, l=..., this=<optimized out>, l=...) at /usr/include/qt5/QtCore/qlist.h:828
#1  0x00007ffff7f6e0b2 in Grantlee::NodeList::NodeList (this=<optimized out>, list=..., this=<optimized out>, list=...) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/lib/node.cpp:121
#2  0x00007ffff4e084ab in BlockNode::render (this=0x4340a0, stream=<optimized out>, c=0x7fffffffd728) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/loadertags/block.cpp:123
#3  0x00007ffff7f6dcf8 in Grantlee::NodeList::render (this=this@entry=0x7fffffffd0b0, stream=stream@entry=0x7fffffffd6a0, c=c@entry=0x7fffffffd728) at /usr/include/qt5/QtCore/qlist.h:559
#4  0x00007ffff4e0a250 in ExtendsNode::render (this=<optimized out>, stream=<optimized out>, c=<optimized out>) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/loadertags/extends.cpp:159
#5  0x00007ffff7f6dcf8 in Grantlee::NodeList::render (this=0x4308d8, stream=0x7fffffffd6a0, c=0x7fffffffd728) at /usr/include/qt5/QtCore/qlist.h:559
#6  0x00007ffff7f63d2f in Grantlee::TemplateImpl::render (this=<optimized out>, stream=stream@entry=0x7fffffffd6a0, c=c@entry=0x7fffffffd728)
    at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/lib/template.cpp:92
#7  0x00007ffff4e05f60 in ConstantIncludeNode::render (this=0x43bf90, stream=0x7fffffffd6a0, c=0x7fffffffd728) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:312
#8  0x00007ffff7fbfdc0 in ForNode::renderLoop (c=<optimized out>, stream=<optimized out>, this=<optimized out>) at /usr/include/qt5/QtCore/qlist.h:563
#9  ForNode::render (this=<optimized out>, stream=<optimized out>, c=0x7fffffffd728) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/defaulttags/for.cpp:214
#10 0x00007ffff7f6dcf8 in Grantlee::NodeList::render (this=0x4305f8, stream=0x7fffffffd6a0, c=0x7fffffffd728) at /usr/include/qt5/QtCore/qlist.h:559
#11 0x00007ffff7f63d2f in Grantlee::TemplateImpl::render (this=<optimized out>, stream=0x7fffffffd6a0, c=0x7fffffffd728) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/lib/template.cpp:92
#12 0x00007ffff7f677e1 in Grantlee::TemplateImpl::render (this=0x4303e0, c=0x7fffffffd728) at /usr/src/debug/grantlee5-5.1.0-0.x86_64/templates/lib/template.cpp:79
#13 0x000000000040adaf in main (argc=1, argv=0x7fffffffda28) at /home/buschmann/Dokumente/Entwicklung/Projekte/grantleetest/src/main.cpp:39

New release?

Is there any plan to create a new release?
Last release was in Apr 19, 2016

API Docs

Hi,

the API Docs are unfortunately down. Do you have plans to reactivate them?

Best
Andreas

Add LICENCE file

Is it possible to add a licence file with current grantlee licence on root folder ?

I'm integrating grantlee to vcpkg dependencies manager.

Enums cannot be compared in Qt 5

3b1931e added operator< to MetaEnumVariable. However, contrary to the commit message, no call to QMetaType::registerComparators is made.

In Qt 6, this works because it uses introspection to determine if operator< is implemented in the class. However, in Qt 5 the call must be explicit.

Oddly, it seems to work on most platforms anyway, somehow… except 64-bit PowerPC. On this platform, using Qt 5.15 + KDE Patch Collection, and GCC 8.5.0, with -O2, or -O0 -fstack-protector -fschedule-insns -fmove-loop-invariants -finline-functions-called-once -fguess-branch-probability (minimum optimisation flags needed to trigger):

FAIL!  : TestBuiltinSyntax::testEnums(gadget-enums-compare05) Compared values are not the same                                          
   Actual   (result): "true"                                 
   Expected (output): "false"                                                                                                           
   Loc: [/usr/src/packages/user/grantlee/src/grantlee-5.3.1/templates/tests/testbuiltins.cpp(482)]
PASS   : TestBuiltinSyntax::testEnums(gadget-enums-compare06)                                                                           
FAIL!  : TestBuiltinSyntax::testEnums(gadget-enums-compare07) Compared values are not the same
   Actual   (result): "false"                                                                                                           
   Expected (output): "true"                                                                                                            
   Loc: [/usr/src/packages/user/grantlee/src/grantlee-5.3.1/templates/tests/testbuiltins.cpp(482)]                                      

Adding a call to registerComparators in testbuiltins makes it pass:

diff --git a/templates/tests/testbuiltins.cpp b/templates/tests/testbuiltins.cpp
index fe7e4ed..82a065d 100644
--- a/templates/tests/testbuiltins.cpp
+++ b/templates/tests/testbuiltins.cpp
@@ -298,6 +298,7 @@ void TestBuiltinSyntax::testObjects()
   Q_UNUSED(s3);
 
   QMetaType{qMetaTypeId<MetaEnumVariable>()}.create(nullptr);
+  QMetaType::registerComparators<MetaEnumVariable>();
 }
 
 void TestBuiltinSyntax::testTruthiness_data()
    Start 2: testbuiltins
1/1 Test #2: testbuiltins .....................   Passed    0.25 sec

100% tests passed, 0 tests failed out of 1

Commit 00a053f breaks nested templates

Commit 00a053f replaces '> >' by '>>' in multiple places, breaking nested templates:

/usr/include/grantlee/context.h:236:31: error: '>>' should be '> >' within a nested template argument list
   QList<QPair<QString, QString>> externalMedia() const;

Grantlee doesn't build with Qt dev branch (5.7)

Qt 5.7 doesn't support c++98 any more, so grantlee needs some cmake magic to turn on c++11 if Qt >= 5.7 is detected.

Currently I get a build error:
qobject.h:316:70: error: ‘&’ cannot appear in a constant-expression typedef QtPrivate::FunctionPointer<decltype(&Func2::operator())> SlotType ;

Consider granting the Context class virtual functions

I'm currently experimenting with using the Grantlee_Templates library as a replacement for the (very) basic templating language that the Shibboleth SP project provides to render HTML error report pages:

https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPErrors

It's working well so far, but the issue that I'm running into is that the templating API of the Shibboleth SP project uses dynamic variable lookup, i.e. there is a TemplateParameters class with a getParameter(const char* varName) method that gets invoked at runtime to look up the desired variable from a set of different possible sources in a well-defined order.

In my replacement POC I have access to such a TemplateParameters instance, but I can't "plug it in" to the Grantlee templating system because Context::lookup is declared as non-virtual, so I have no chance of modifying how variables are looked up at runtime. If instead it were declared virtual, I could create a subclass of Context that dispatches runtime lookup of variables to the TemplateParameters instance (though only after first failing the original Context::lookup --the ability for local variables to be pushed onto the stack at runtime by various tags like for and with must stay respected).

So my question is this: would you consider virtualizing Context::lookup and related others to allow end users to customize runtime variable lookup?

Strange behaviour of timesince filter

Hello.
I'm using the timesince filter and I'm getting a strange behaviour with these input/templates.
When outputting directly the times they are correct but using them through timesince doesn't work ?
By the way I added support of seconds to timesince which I will propose as a pull request if you're interested in.

Regards,

Sébastien Grignard.

example.zip

Splitting a list into "N" chunks

I'm trying to take a list of objects (QList<QObject *>), split it into "N" chunks, and build a separate (HTML) table for each chunk.

I'm doing something like:

  {% range objectList.count as startNum %}
    {% if startNum|divisibleby:16 %}
      {% include "table.html.django" %}
    {% endif %}
  {% endrange %}

I've tried this for table.html.django:

<table>
     <thead><tr><th>Name</th></tr></thead>
     <tbody>
       {% range startNum startNum|add:16 as num %}
       <tr><td>{{ num }} {{ objectList.num.name }}</td></tr>
       {% endrange %}
   </tbody>
 </table>

But that doesn't reference the list item properly and I don't see how to access a specific item in a list when I have a variable ("num"). Is there a way to do this?

I tried using slice, but looking at SliceFilter::doFilter() it seems like it only works on lists of strings. Is that correct?

Any suggestions on how to approach this?

(Also posted on StackOverflow, but no grantlee tag, so I'm guessing not too many people are using it over there.)

saving libs in grantlee/major.minor/ folder causes packaging issues on macOS

Your cmake puts some of the libs in a lib/grantlee/major.minor folder. I don't think it is a good practice on any platform and that all libraries should be instead versioned via their actual filenames (accompanied by a generic symlink), not via their parent folder's name. However, it in particular causes the macOS packaging to fail due to limitations imposed by Xcode codesign tool:

(...) If you do do this, do not use periods in the directory names. The code signing machinery interprets directories with periods in their names as code bundles and will reject them if they don't conform to the expected code bundle layout

(per: https://developer.apple.com/library/archive/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG201)

Also see following for reference:
https://bugs.kde.org/show_bug.cgi?id=419272
https://bugs.kde.org/show_bug.cgi?id=420351
https://stackoverflow.com/questions/37737829/codesign-osx-app-bundle-with-periods-in-macos-directory-names

A proposed solution is to add a version number to the libraries filenames or at least use an underscore in place of a dot in Grantlee5_MAJOR_MINOR_VERSION_STRING variable

Relating two integers with an if-statement

I'm using TexturePacker which uses Grantlee templates internally. I'm having an elementary problem. Making an if-statement work. I actually can't find a single case in Grantlee or in Texture packer where there is an example relating two numbers. So here goes:

Doesn't work
{% if 8 > 7 %}bigger{% endif %}

Doesn't work
{% if 7 == 8 %}not equal{% endif %}

Works
{% if myobject.is_true %}yes{% endif %}

I'm trying to decide if this is a TexturePacker bug or a Grantlee bug. Since I haven't seen this in any Grantlee documentation, I decided to start here.

Grantlee fails to build on Qt dev branch (5.13) with GCC 8.2

When building Grantlee on Gentoo Linux with GCC 8.2 and Qt -dev branch (5.13 pre), Grantlee fails to build due to an incomplete type error in templates/lib/lexer_p.h. See below.

I'm not precisely sure why this would have worked before because lexer_p.h seems to be using enough of the Lexer class in some of the defined functions to have warranted requiring a complete type definition for QList early. Possibly older Qt headers had included QList already somehow and they managed to clean it up?

Either way I'll have a PR submitted if you want or you can just fix a different way, it's up to you.

--- (gcc -v)
...
gcc version 8.2.0 (Gentoo 8.2.0-r5 p1.6)

--- (qmake -v)
QMake version 3.1
Using Qt version 5.13.0 in /home/kde-svn/qt5/lib

--- (error log)

# kdesrc-build running: '/usr/bin/ninja' '-j17' # from directory: /kdesrc/build/kf5/grantlee [1/135] Automatic MOC for target Grantlee_Templates [2/135] Automatic MOC for target textdocument_test_builtins [3/134] Automatic MOC for target Grantlee_TextDocument
[4/133] Automatic MOC for target myplugin
[5/132] Automatic MOC for target main_app
[6/131] Automatic MOC for target template_test_builtins
[7/130] Building CXX object templates/lib/CMakeFiles/Grantlee_Templates.dir/lexer.cpp.o
FAILED: templates/lib/CMakeFiles/Grantlee_Templates.dir/lexer.cpp.o 
/usr/lib/ccache/bin/c++  -DGrantlee_Templates_EXPORTS -DPLUGINS_PREFER_DEBUG_POSTFIX=0 -DQT_CORE_LIB -DQT_NETWORK_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_QML_LIB -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -Itemplates/lib -I/kdesrc/src/kf5/grantlee/templates/lib -Itemplates/lib/Grantlee_Templates_autogen/include -I/kdesrc/src/kf5/grantlee/templates/lib/../scriptabletags -isystem /home/kde-svn/qt5/include -isystem /home/kde-svn/qt5/include/QtQml -isystem /home/kde-svn/qt5/include/QtNetwork -isystem /home/kde-svn/qt5/include/QtCore -isystem /home/kde-svn/qt5/./mkspecs/linux-g++ -pipe -O3 -march=native -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common  -pedantic-errors -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -fPIC -std=gnu++11 -MD -MT templates/lib/CMakeFiles/Grantlee_Templates.dir/lexer.cpp.o -MF templates/lib/CMakeFiles/Grantlee_Templates.dir/lexer.cpp.o.d -o templates/lib/CMakeFiles/Grantlee_Templates.dir/lexer.cpp.o -c /kdesrc/src/kf5/grantlee/templates/lib/lexer.cpp
In file included from /kdesrc/src/kf5/grantlee/templates/lib/lexer.cpp:21:
/kdesrc/src/kf5/grantlee/templates/lib/lexer_p.h:56:16: error: field ‘m_tokenList’ has incomplete type ‘QList<Grantlee::Token>’
QList<Token> m_tokenList;
             ^~~~~~~~~~~
In file included from /home/kde-svn/qt5/include/QtCore/qglobal.h:1212,
                from /home/kde-svn/qt5/include/QtCore/qchar.h:43,
                from /home/kde-svn/qt5/include/QtCore/qstring.h:48,
                from /home/kde-svn/qt5/include/QtCore/QString:1,
                from /kdesrc/src/kf5/grantlee/templates/lib/statemachine_p.h:24,
                from /kdesrc/src/kf5/grantlee/templates/lib/textprocessingmachine_p.h:24,
                from /kdesrc/src/kf5/grantlee/templates/lib/lexer_p.h:24,
                from /kdesrc/src/kf5/grantlee/templates/lib/lexer.cpp:21:
/home/kde-svn/qt5/include/QtCore/qtypeinfo.h:212:1: note: declaration of ‘class QList<Grantlee::Token>’
Q_DECLARE_MOVABLE_CONTAINER(QList);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/kdesrc/src/kf5/grantlee/templates/lib/lexer.cpp:274:43: error: return type ‘class QList<Grantlee::Token>’ is incomplete
QList<Token> Lexer::tokenize(TrimType type)
                                          ^

Internationalization

I got a bug in Cutelyst that i18n tag was not working, besides the needed changes in Cutelyst I kept getting:
grantlee.template: "Invalid block tag on line 0: 'i18n''. Did you forget to register or load this tag?" grantlee.template: "Invalid block tag on line 0: 'i18n''. Did you forget to register or load this tag?"
even after:
engine->addDefaultLibrary(QStringLiteral("grantlee_i18ntags"));
which is what grantlee tests do, what am I missing?
Thanks

Qt Script deprecation

Are there any plans to update/modify Grantlee when they eventually remove Qt Script?

Qt Script has been marked as a deprecated module for many releases now.

Unfortunately, their "solution" is to replace Qt Script with the QJS* classes in the Qt QML module which means pulling in all the QML stuff...

SliceFilter::doFilter does not work with ranges

SliceFilter::doFilter tries splits the input into parts left and right from the ":" that divides the range to output.

  auto splitterIndex = argString.get().indexOf(QLatin1Char(':'));
  QString inputString = getSafeString(input);
  if (splitterIndex >= 0) {
    auto left = argString.get().left(splitterIndex).get().toInt();
    auto right = argString.get().right(splitterIndex).get().toInt();

But the right hand part is not correctly extracted, because QString::right expects the amount of characters from the right. It seems the code should be using QString::mid with the correct index adjustments instead.

Test cases:
data|slice:"0:10" returns the empty string, because it uses only "0" as right side.
data|slice:"00:-1" works because because "00" and "-1" are the same lenght.

When there is a template error the error line is not set

If I try to render a template like:

"

{{ "foo" bar }}"

I get:
grantlee.template: "Could not parse the remainder, bar from "foo" bar, line 0, admin/index.html"
which clearly isn't line 0 (always set to 0), I tried to find where this is failing (as it's failing since a long time) but failed.

Date filter tests fail in Debian

Hi, I am triaging bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917711 in Debian. There seems to be a problem with the Grantlee date filter, which I have narrowed down to the following snippet: in this line the date object, which has to be formatted, is received serialized in a string with template "yyyy-MM-ddThh:mm:ss", but the actual string I see is "2008-01-01T00:00:00.000" (notice the additional milliseconds digits). I can see adding this line just at the beginning of the functions:

std::cerr << "input = " << QString(getSafeString(input)).toStdString() << std::endl;

If I change the decoding template to "yyyy-MM-ddThh:mm:ss.000", then the test is fixed, but I am not sure this is the right internal protocol. Could you please assist me in finding what is the clean solution?

Let me add that the date object to be expanded in the template is generated here and is passed to the template engine a few lines below in unserialized form. So it seems there is a disagreement on the serialization template between the code that serializes it before calling the filter and the filter itself: what is the actual template that is meant to be used here?

Thank you very much for your help!

Crash on '{{ }}' in template

We use grantlee to generate user configureable filenames where the user sets the pattern in a qtextedit.
While testing we noticed that the pattern '{{ }}' crashes the engine, while '{{}}' does not. It must contain at least one space for the crash to occure.

--Type <RET> for more, q to quit, c to continue without paging--

Thread 1 ".mixxx-wrapped" received signal SIGSEGV, Segmentation fault.
0x00007ffff7ec9c16 in Grantlee::Parser::takeNextToken() () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
(gdb) bt
#0  0x00007ffff7ec9c16 in Grantlee::Parser::takeNextToken() () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#1  0x00007ffff7eca442 in Grantlee::ParserPrivate::parse(QObject*, QStringList const&) () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#2  0x00007ffff7ecab82 in Grantlee::Parser::parse(Grantlee::TemplateImpl*, QStringList const&) () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#3  0x00007ffff7ed2fc1 in Grantlee::TemplatePrivate::compileString(QString const&) () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#4  0x00007ffff7ed31c7 in Grantlee::TemplateImpl::setContent(QString const&) () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#5  0x00007ffff7eb6693 in Grantlee::Engine::newTemplate(QString const&, QString const&) const () from /nix/store/360v6zacms0cdxyq0wxjkjjrsli20q4m-grantlee-5.2.0/lib/libGrantlee_Templates.so.5
#6  0x0000000000b5c8b9 in TrackExportWorker::updateTemplate (this=0x7ffe934eb880) at /home/poelzi/Projects/mixxx-export/src/library/export/trackexportworker.cpp:139
#7  0x0000000000b58103 in TrackExportDlg::updatePreview (this=0x7ffe934e41d0) at /home/poelzi/Projects/mixxx-export/src/library/export/trackexportdlg.cpp:222
#8  0x00007ffff55b8f7e in ?? () from /nix/store/nwgzcffcjscw62lrfbijkcjbbay6647i-qtbase-5.15.2/lib/libQt5Core.so.5
#9  0x00007ffff6fee092 in QLineEdit::textChanged(QString const&) () from /nix/store/nwgzcffcjscw62lrfbijkcjbbay6647i-qtbase-5.15.2/lib/libQt5Widgets.so.5
#10 0x00007ffff6ff485b in ?? () from /nix/store/nwgzcffcjscw62lrfbijkcjbbay6647i-qtbase-5.15.2/lib/libQt5Widgets.so.5
#11 0x00007ffff55b8fb0 in ?? () from /nix/store/nwgzcffcjscw62lrfbijkcjbbay6647i-qtbase-5.15.2/lib/libQt5Core.so.5

One filter test (formatfiltertest07) fails on i586

As the subject says, formatfiltertest07 fails for some reason on i586:

[  131s] QWARN  : TestFilters::testStringFilters(filter-filesizeformat07) Failed to convert input file size into floating point value.
[  131s] FAIL!  : TestFilters::testStringFilters(filter-filesizeformat07) Compared values are not the same
[  131s]    Actual   (result): "999 bytes 1.00 KB 10.00 KB 1000.00 KB 1.00 MB 50.00 MB 1000.00 MB 1.00 GB 1.00 TB 1.00 PB 2.00 EB 1.00 ZB 1000.00 ZB 2000.00 YB 0 bytes 0 bytes -100 bytes -50.00 MB"
[  131s]    Expected (output): "999 bytes 1.00 KB 10.00 KB 1000.00 KB 1.00 MB 50.00 MB 1000.00 MB 1.00 GB 1.00 TB 1.00 PB 2.00 EB 1.00 ZB 1.00 YB 2000.00 YB 0 bytes 0 bytes -100 bytes -50.00 MB"

Build with MSVC 2017?

I have been integrating QWebEngine/grantlee into an existing Qt 5.9 project on macOS and it's working great! Unfortunately when I went to the Windows side I discovered that QWebEngine doesn't work with the MinGW compiler. So it looks like I have to move my 10+ year-old project to MSVC in order to use QWebEngine.

I am having troubles building a grantlee DLL with MSVC:

-- The C compiler identification is MSVC 19.10.25019.0
-- The CXX compiler identification is MSVC 19.10.25019.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "C:/Program Files (x86)/Microsoft Visual
  Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/bin/HostX86/x64/cl.exe" is
  not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/dev/HemoSpat/3rd_Party/grantlee/grantlee-build/CMakeFiles/CMakeTmp

  Run Build Command:"nmake" "cmTC_36a6c.vcxproj" "/p:Configuration=Debug"
  "/p:VisualStudioVersion=15.0"

  Microsoft (R) Program Maintenance Utility Version 14.10.25019.0

  NMAKE : fatal error U1065: invalid option ':'

  Stop.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:8 (project)

Has anyone successfully built grantlee using MSVC 2017 & CMake?

Operator declared deprecated warnings in templates\defaulttags\if_p.h

With MSVC 16.11.17 I get the following warnings:

[77/154] Building CXX object templates\defaulttags\CMakeFiles\grantlee_defaulttags.dir\if.cpp.obj
C:\Users\Joerg\source\repos\JoergAtGithub\grantlee\templates\defaulttags\if_p.h(315): warning C4996: 'QVariant::operator >': was declared deprecated
C:\Users\Joerg\source\repos\JoergAtGithub\grantlee\templates\defaulttags\if_p.h(317): warning C4996: 'QVariant::operator >=': was declared deprecated
C:\Users\Joerg\source\repos\JoergAtGithub\grantlee\templates\defaulttags\if_p.h(319): warning C4996: 'QVariant::operator <': was declared deprecated
C:\Users\Joerg\source\repos\JoergAtGithub\grantlee\templates\defaulttags\if_p.h(321): warning C4996: 'QVariant::operator <=': was declared deprecated

5.2.0: compile time warnings

Summary stats:

[tkloczko@barrel SPECS]$ rpmbuild -ba --with check --with failing_tests grantlee-qt5.spec --quiet 2>&1 | grep -- -W | sed 's/.*\[//; s/\]//' | sort | uniq -c | sort -nr
      4 -Wdeprecated-declarations
      1 -Wstringop-overflow=
      1 -Wrange-loop-construct

And full log:

/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if_p.h: In member function 'QVariant IfToken::evaluate(Grantlee::Context*) const':
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if_p.h:314:65: warning: 'bool QVariant::operator>(const QVariant&) const' is deprecated [-Wdeprecated-declarations]
  314 |       return mArgs.first->evaluate(c) > mArgs.second->evaluate(c);
      |                                                                 ^
In file included from /usr/include/qt5/QtCore/qlocale.h:43,
                 from /usr/include/qt5/QtCore/QLocale:1,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/abstractlocalizer.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/context.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/node.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:21:
/usr/include/qt5/QtCore/qvariant.h:471:31: note: declared here
  471 |     QT_DEPRECATED inline bool operator>(const QVariant &v) const
      |                               ^~~~~~~~
In file included from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:22:
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if_p.h:316:66: warning: 'bool QVariant::operator>=(const QVariant&) const' is deprecated [-Wdeprecated-declarations]
  316 |       return mArgs.first->evaluate(c) >= mArgs.second->evaluate(c);
      |                                                                  ^
In file included from /usr/include/qt5/QtCore/qlocale.h:43,
                 from /usr/include/qt5/QtCore/QLocale:1,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/abstractlocalizer.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/context.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/node.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:21:
/usr/include/qt5/QtCore/qvariant.h:473:31: note: declared here
  473 |     QT_DEPRECATED inline bool operator>=(const QVariant &v) const
      |                               ^~~~~~~~
In file included from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:22:
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if_p.h:318:65: warning: 'bool QVariant::operator<(const QVariant&) const' is deprecated [-Wdeprecated-declarations]
  318 |       return mArgs.first->evaluate(c) < mArgs.second->evaluate(c);
      |                                                                 ^
In file included from /usr/include/qt5/QtCore/qlocale.h:43,
                 from /usr/include/qt5/QtCore/QLocale:1,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/abstractlocalizer.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/context.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/node.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:21:
/usr/include/qt5/QtCore/qvariant.h:467:31: note: declared here
  467 |     QT_DEPRECATED inline bool operator<(const QVariant &v) const
      |                               ^~~~~~~~
In file included from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:22:
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if_p.h:320:66: warning: 'bool QVariant::operator<=(const QVariant&) const' is deprecated [-Wdeprecated-declarations]
  320 |       return mArgs.first->evaluate(c) <= mArgs.second->evaluate(c);
      |                                                                  ^
In file included from /usr/include/qt5/QtCore/qlocale.h:43,
                 from /usr/include/qt5/QtCore/QLocale:1,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/abstractlocalizer.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/context.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/lib/node.h:26,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.h:24,
                 from /home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaulttags/if.cpp:21:
/usr/include/qt5/QtCore/qvariant.h:469:31: note: declared here
  469 |     QT_DEPRECATED inline bool operator<=(const QVariant &v) const
      |                               ^~~~~~~~
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaultfilters/lists.cpp: In member function 'virtual QVariant MakeListFilter::doFilter(const QVariant&, const QVariant&, bool) const':
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaultfilters/lists.cpp:199:26: warning: loop variable 'var' of type 'const QVariant&' binds to a temporary constructed from type 'QString' [-Wrange-loop-construct]
  199 |     for (const QVariant &var :
      |                          ^~~
/home/tkloczko/rpmbuild/BUILD/grantlee-5.2.0/templates/defaultfilters/lists.cpp:199:26: note: use non-reference type 'const QVariant' to make the copy explicit or 'const QString&' to prevent copying
/usr/include/qt5/QtCore/qvector.h: In member function 'append':
lto1: warning: writing 16 bytes into a region of size 8 [-Wstringop-overflow=]
/usr/include/qt5/QtCore/qarraydata.h:129:8: note: at offset [16, 24] into destination object '<anonymous>' of size 24
  129 | struct QTypedArrayData
      |        ^

BTW: do you have any plans to make new release? (5.2.1?)

Comparing an integer and a string fails

This fails:
{% if 8 == '8' %}equal{% endif %}
yes, both things are not the same and I dunno how DJango handles this, so this might at least serve for "documentation" of duplicated bugs..

With Ninja: Always recompiles all source files after configuration run (`cmake .`)

See here:

[kfunk@kerberos ninjabuild 408K]% ninja                                                                                                                                                                                
[45/173] Automatic moc for target Grantlee_TextDocument
Generating moc compilation Grantlee_TextDocument_automoc.cpp
[47/173] Automatic moc for target htmlbuildertest_exec
Generating moc source htmlbuildertest.moc
Generating moc compilation htmlbuildertest_exec_automoc.cpp
[51/173] Automatic moc for target plainmarkupbuildertest_exec
Generating moc source plainmarkupbuildertest.moc
Generating moc compilation plainmarkupbuildertest_exec_automoc.cpp
[52/173] Automatic moc for target textdocument_test_builtins
Generating moc source textdocument_test_builtins_automoc.dir/moc_coverageobject_XLBJD23RFJFDRJ.cpp
Generating moc compilation textdocument_test_builtins_automoc.cpp
[54/173] Building CXX object templates/lib/CMakeFiles/Grantlee_Templates.dir/Grantlee_Templates_automoc.cpp.o^C
ninja: build stopped: interrupted by user.
[kfunk@kerberos ninjabuild 456K -2-]% ninja                                                                                                                                                                            
[22/140] Building CXX object textdocument/lib/CMakeFiles/Grantlee_TextDocument.dir/mediawikimarkupbuilder.cpp.o^C
ninja: build stopped: interrupted by user.
[kfunk@kerberos ninjabuild 456K -2-]% cmake .                                                                                                                                                                          
-- Enabling TR1 container tests
-- Doxygen and dot found. make docs target is available
-- Could NOT find LCov (missing:  LCOV_EXECUTABLE GENHTML_EXECUTABLE)
-- Could NOT find Cccc (missing:  CCCC_EXECUTABLE)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kfunk/devel/src/grantlee/ninjabuild
[kfunk@kerberos ninjabuild 456K]% ninja                                                                                                                                                                                
[51/169] Building CXX object textdocument/lib/CMakeFiles/Grantlee_TextDocument.dir/mediawikimarkupbuilder.cpp.o^C
ninja: build stopped: interrupted by user.

Observations:

  • Before cmake ., 140 targets needed to be built
  • After cmake ., 169 targets need to be built

=> There seems be something wrong. Likely a bogus DEPENDS/BYPRODUCT? I haven't investigated it thoroughly yet.

Not full escape features

I've figured out that Grantlee does not support all escape features which are described here: lack of conversion double quote.
Therefore Grantlee cannot generate XML of HTML-code if a variable comprises double-quotes.
MB, I was doing something wrong.
But it looks like just adding one line into OutputStream::escape() will fix it:
temp.replace(QLatin1Char('"'), QStringLiteral("&quot;"));

I've done it on my side and it works as intended now.
Of course, I broke tests but it seems this is the correct fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.