steveire / grantlee

Libraries for text templating with Qt
Other
141 stars 50 forks source link

Problem with widthratio #74

Open 892768447 opened 2 years ago

892768447 commented 2 years ago

https://github.com/steveire/grantlee/blob/master/templates/defaulttags/widthratio.cpp#L75

test on {% widthratio 2 1 0.5 %}

I think it will return 1, but it returns 2

  Grantlee::Context context;
  context.insert("DPI", 0.5);
  Grantlee::Engine engine;
  Grantlee::Template tpl =
      engine.newTemplate("{width: {% widthratio 2 1 DPI %};}", "style");

  qInfo() << 2 * 0.5 << int(2 * 0.5);
  qInfo() << tpl->render(&context);

Output: 1 1 "{width: 2;}"