using mustapas from leledumbo inside a DLL lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- mtournay · 2020-02-18 16:56 Hello I try to use https://github.com/leledumbo/mustapas from leledumbo but it seems to be not working from a dll, same code from a simple console program is functionnal. When I try to use parameters, output stream is empty. After some investigations, i found that Code: [Select]  AssignStream(Output,Result);   Rewrite(Output); and Code: [Select]  Write(Output,Value);              is disfunctionnal : when I write directly in the stream, Code: [Select]  result.Write(value[1], length(value)); output stream is quite good (there's some other problems I believe related to input stream and I see \r\n string at each line) does someone already had this issue ? ---------------------------------------------------------------------- mtournay · 2020-02-19 08:07 Hi all I just forked mustapas. The code does not use iostream anymore and run correctly from DLL. https://github.com/mtournay/mustapas ---------------------------------------------------------------------- devEric69 · 2020-02-19 08:32 Your improvements (thanks for sharing) can't be "push"ed in the original leledumbo/mustapas GitHut? ---------------------------------------------------------------------- mtournay · 2020-02-19 08:40 Hi Before asking for PR, I would like to discuss with leledumbo about it (I'd like to know why at first he use iostream) ---------------------------------------------------------------------- devEric69 · 2020-02-19 08:54 That's for sure: leledumbo is the only one who can decide if your improvements can be "push"ed in his GitHub. ==>All I wanted to say, is that it's always better to avoid the fragmentation of a code that provides an evolution of the same functionality, as far as it is possible. ---------------------------------------------------------------------- Thaddy · 2020-02-19 09:26 I don't think avoiding iostream is a good thing, but I leave it up to Leledumbo to decide. Reason being that under Linux everything is a file and the original code seems to be designed with that in mind.. It may be that a shared library should be notified of the IO handles in the main program, though. I can see that point if that is what you mean. ---------------------------------------------------------------------- mtournay · 2020-02-19 09:57 You both are right And that's why i didn't PR for now both codes are functionnal, and we have to decide if we reunite with a define with/without iostream (or any other solution) or leave both library. I don't like the idea of two libraries : i believe I 'm gonna need conditionnal sections, inverted, ... so IF I improve the code, it's better for everyone if there's only one unit ---------------------------------------------------------------------- Roland57 · 2020-02-19 12:01 Hello! I just discover Mustache. Could someone be kind enough to provide an usage example? Regards. Roland ---------------------------------------------------------------------- mtournay · 2020-02-19 13:33 1. create a file somewhere. inside this file, put Code: [Select]hello {{name}}!2. load this file in a stream 3. create a json object with {name: "world"} 4. call mustapas.render and get result in third param 5. put result where you want (screen, http result, ...) here is a sample code Code: [Select]program test_mustache; uses classes, fpjson, mustapas; var   input: TFileStream;   output: TStringStream;   params: TJSONObject; begin   input := TFileStream.Create('__path__to_your_file', fmOpenRead);   output:= TStringStream.Create('');   params := TJSONObject.Create(['name', 'world']);   Render(input, params, output);   writeln(output.DataString);   params.free;   input.free;   output.free; end. more info on mustache https://mustache.github.io/mustache.5.html ---------------------------------------------------------------------- Roland57 · 2020-02-19 13:55 @mtournay Thank you.