If you read the earlier Quick Tour and Views and Events chapters, you already have a measure of experience with Eco (Embedded CoffeeScript) templates. This chapter will focus on Eco, beginning with basic usage in order that you understand Eco's moving parts, then progressing to more complex patterns and the use of third-party helper functions. Backbone components will make an appearance in many of the examples, in order to provide practical guidance for application development.
editor.out.append functions are in fact generated on the fly from Eco templates containing CoffeeScript.
This book chooses Eco for rendering dynamic HTML for the following reasons. To remain manageable, templates must keep their interpolated programming code from growing too verbose, lest the readability of the template suffer too greatly. This is not a problem when the dynamic elements are simple properties, but in almost every application, logic (and therefore, arbitrary programming code) is required for most templates. The so-called logic-less approach to templating, promoted by Handlebars and other Mustache implementations, employs special syntax and custom helpers to move the arbitrary code out of the templates, but this indirection can grow cumbersome. Eco leverages all of CoffeeScript's clean, readable power for a solution that gets the job done with a minimum of fuss.