December 2021
Intermediate to advanced
510 pages
11h 20m
English
As the final improvement to the mdp tool, you’ll update the way it writes the final HTML file. You currently have the HTML header and footer hard-coded in the program. It’s a good start, but it makes the tool less flexible and harder to maintain. To address this issue, use the html/template package to create a data-driven template that allows you to inject code at predefined places at runtime.
Templates are perfect in situations where you need to write files with some fixed content and you want to inject dynamic data at runtime. Go provides another template package called text/template, but you should use the html/template when writing HTML content. Both packages share a similar interface, ...
Read now
Unlock full access