3 ms·
Did something similar. But instead of adding plain-text to HTML output, wrote a DOM parser in C that loads a HTML template and then adds the response into prope
by habibur 3y ago
Did something similar. But instead of adding plain-text to HTML output, wrote a DOM parser in C that loads a HTML template and then adds the response into proper place of the DOM tree.
- actionfromafar 3y agoThat sounds hard!
- gchamonlive 3y agoDid you use regex for the html part?
- habibur 3y agoWrote a code parser. Not regexp. Found the old code on disk, snapshot here. The DOM parser, manipulator and free was 240 LOC. https://codeshare.io/X8RQxl https://codeshare.io/X8RQxl
- actionfromafar 3y agoWitchcraft! ;-) This is incredible.
- slmjkdbtl 3y agoWhat's the benefit of parsing an HTML template, over just putting HTML string together with the data from the backend like "<p>your name: " + name + "</p>"?
- habibur 3y agoIn DOM you can add content gradually and asynchronously, which gets harder using HTML template. Further you can read back previously added contents and make additional chagnes based on those. Like summing up table columns, or adding links to the first column values, or removing or fixing links based on authorization, to name a few.
- bawolff 3y agoWell XSS prevention for one. Syntax aware template languages are a thing in the web space. They aren't the most popular but security people often like them because they lead to less mistakes. Some examples include soy, latte, and hack's XHP.