Skip to content

fcl-mustache: incorrect newlines in output

Summary

TMustache renders a list sometimes with and sometimes without extra newlines.

System Information

  • Operating system: Linux, Ubuntu 21.10
  • Processor architecture: x86-64
  • Compiler version: 3.2.2+dfsg-1ubuntu2

Steps to reproduce

program reproduce;

uses jsonparser, fpmustache;

const
  LF = #10;
  Template =
    '{{#list}}' + LF +
    '* {{.}}'   + LF +
    '{{/list}}' + LF +
    '{{#list}}' + LF +
    '* {{.}}'   + LF +
    '{{/list}}';
  Json = '{ "list": [ "one", "two", "three" ] }';

begin
  WriteLn(TMustache.Render(Template, Json));
  ReadLn;
end.

Example Project

So the template is:

{{#list}}
* {{.}}
{{/list}}
{{#list}}
* {{.}}
{{/list}}

What is the current bug behavior?

The template contains two exactly the same lists, however, the rendering is one time with extra newlines and one time without. The rendering is:

* one
* two
* three

* one

* two

* three

What is the expected (correct) behavior?

Correct rendering is:

* one
* two
* three
* one
* two
* three

http://rickkas7.github.io/mustache/ yields the correct rendering with the same template and JSON data.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information