🎉Getting Started
Corgi distinguishes between four file types: main files, library files, template files, and included files. While you'll learn about the last three later, let's talk about main files:
The main file is the file that gets compiled to a Go function. Therefore, unlike the other file types, it must define the name and parameters of it's output function. This is done by adding a Go function header without return value to your file:
As you can see by the cryptic import alias and name for the io.Writer
, corgi tries it best to avoid name collisions.
To do that, the corgi CLI prefixes all its identifiers with __corgi_
. In turn, it reserves all identifiers starting with that name for current or future use.
You can also import other packages and use the types, functions, variables, and constants in it in your template.
After you've written the function header, the content of generated document begins. Everything written there will be used to render the document.
Let's start with something very basic and create a p
element:
From this point on, examples will only include a func
directive, if its parameters are relevant for the example. When you also want to try the example, just give the function any name and no parameters!
Last updated