inja
                                
                                 inja copied to clipboard
                                
                                    inja copied to clipboard
                            
                            
                            
                        templates with BOM (for UTF-8) fail to render
When I have a template file encoded in UTF-8 with BOM (Byte-Order-Mark) and right after that I start an "if" sequence I get this error:
terminate called after throwing an instance of 'inja::ParserError' what(): [inja.exception.parser_error] (at 3:2) else without matching if
You can add a BOM using uconv:
$ uconv --add-signature -t utf-8 test.txt >test2.txt $ cat test2.txt #if name Hello: %name% #else Hello: #endif $ hexdump test2.txt 0000000 bbef 23bf 6669 6e20 6d61 0a65 6548 6c6c 0000010 3a6f 2520 616e 656d 0a25 6523 736c 0a65 0000020 6548 6c6c 3a6f 230a 6e65 6964 0a66 000002e
(notice the extra 0xbbef)
This is using: env.set_line_statement("#"); env.set_expression("%", "%");
Can you check if it works with the latest master commit?
Yes, that fixes it. But wouldn't it be more correct to keep the byte order mark in the output if it was in the original template? Also, for HTML files, I think it can be found not only at the beginning of the file, but also in the middle.