Template-based code generation (TBCG) is a synthesis technique that produces code from high-level specifications, called templates. TBCG is a popular technique in model-driven engineering (MDE) given that they both emphasize abstraction and automation. Given the diversity of tools and approaches, it is necessary to classify existing TBCG techniques to better guide developers in their choices. The goal of this article is to better understand the characteristics of TBCG techniques and associated tools, identify research trends, and assess the importance of the role of MDE in this code synthesis approach. We conducted a systematic mapping study of the literature to paint an interesting picture about the trends and uses of TBCG. Our study shows that the community has been diversely using TBCG over the past 15 years. TBCG has greatly benefited from MDE. It has favored a template style that is output-based and high level modeling languages as input. TBCG is mainly used to generate source code and has been applied in a variety of domains. Furthermore, both MDE and non-MDE tools are becoming effective development resources in industry.