File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,27 @@ async function compileTemplate (filePath) {
2121 * @return {Promise }
2222 */
2323async function processHandlebarFile ( filePath , substitutions ) {
24- return processFile ( filePath , ( rawSource ) => {
25- try {
26- const template = Handlebars . compile ( rawSource )
27- return template ( substitutions )
28- } catch ( error ) {
29- debug ( `Error processing template: ${ error } ` )
30- return rawSource
31- }
32- } )
24+ return processFile ( filePath , ( rawSource ) => processHandlebarTemplate ( rawSource , substitutions ) )
25+ }
26+
27+ /**
28+ * Performs a Handlebars string template substitution, and returns the
29+ * resulting string.
30+ *
31+ * @see https://www.npmjs.com/package/handlebars
32+ *
33+ * @param source {string} e.g. 'Hello, {{name}}'
34+ *
35+ * @return {string } Result, e.g. 'Hello, Alice'
36+ */
37+ function processHandlebarTemplate ( source , substitutions ) {
38+ try {
39+ const template = Handlebars . compile ( source )
40+ return template ( substitutions )
41+ } catch ( error ) {
42+ debug ( `Error processing template: ${ error } ` )
43+ return source
44+ }
3345}
3446
3547function writeTemplate ( filePath , template , substitutions ) {
You can’t perform that action at this time.
0 commit comments