Chapter 6. HTML and email template patterns

 

This chapter covers

  • Adding functionality inside templates
  • Nesting templates
  • Using template inheritance
  • Rendering objects to HTML
  • Using email templates

When you’re programmatically creating text or HTML responses in many programming environments, you need to seek out the right library to handle the HTML. Go handles this a little differently. In the standard library, Go provides template handling for both text and HTML. The HTML handling is built on top of the text template engine to add HTML-aware intelligence.

Although the standard library enables you to work with HTML templates, it stops short of having too many opinions. Instead, it provides a foundation along with the ability to extend and combine templates. For example, you could nest templates or have a template inherit from another one. This simple and extensible design allows you to use many common template patterns.

In this chapter, you’ll learn how to extend the functionality inside HTML templates and techniques to use templates together. Along the way, we offer tips, including some related to performance, that can speed up applications. For example, you’ll learn where you can parse a template that can save overall processing time. You’ll then learn how to use text templates when you send email messages.

6.1. Working with HTML templates

6.2. Using templates for email

6.3. Summary

sitemap