Templates
Templates are files that will be transformed by Mr. Smith into Go templates to generate the final files for a scaffolding process.
Variables
The variables for templates in Mr. Smith are classified into two types:
-
data: variables passed in the data property of a file in the
structure
field tree within a builder. Usage:.data.variableName
-
global: global variables, meaning they can be used in all templates. They are defined once in the
global
property inside a builder. Usage:.global.variableName
Extensions
Template files in Mr. Smith can accept any text file extension. However, it is advisable to use one of the extensions below to have Syntax Highlighting in your IDE.
Recommended extensions: *.go.txt, *.go.tpl, *.go.tmpl, *.gtpl, *.tpl.
Examples
Simple example:
Result:
Advanced example:
Result:
To learn more about text templates and how to use them with Mr. Smith, visit the link: Text Templates in Go