Another application that come to mind is making a project that can be described as a static site generator. One of the aspects of a static site generator is that plain text, or markdown source files need to be converted into HTML and injected into an HTML page.
This is where methods like the _.template method in lodash can be useful, so lets take a look at some lodash template method examples.
So a basic lodash template involves passing a string that will be the template as the first argument to the _.template method. This string can contain one or more delimiters that are used to inject data from an object when using the method that is returned when calling the _.template method.
In this basic example I am using the interpolate delimiter that is an equal sign before and opening pointy bracket and percent sign pattern. This kind of syntax is similar to ejs a popular template language used in node.js related projects as a way or writing templates.
There is a significant dereference between using an equals (interpolate) sign and a dash (escape) when delimiters. For the most part when creating a template I would want to use the equal sign so that tags are made in a way that will render in the browser. However in some cases I would want to use a dash so that the resulting string is escaped.
So here I have some arrays of booleans and I want the result of an _.every call to be part of the result in the template.
So then what will be render as the result of a delimiter like that of the escape delimiter does not have to always be just an object property it can be the result of a method like _.every that returns true then all elements in an array are truthy.
So the lodash template method is useful for creating and using templates. However it is not a replacement for other options when it comes to doing this sort of thing. In most applications I might use some dependency outside that of the lodash template method to preform these kinds of tasks. For example when it comes to parsing markdown into HTML I would use marked.js, and in most projects that require a template system I tend to prefer the use of EJS.