Skip to main content

Under the Hood

What CodeBaker does inside, in the order it does it: what each step of the dialog works out, how one file is processed, and how to choose the way a file is written. You do not need any of this to write your first templates. It helps when a result surprises you.


What happens inside the steps​

The work is done in step 2. It resolves the values, reads the mapping and works out the content of every file. Step 3 shows exactly that result, and step 4 writes exactly what step 3 shows, including any edit you made there.


How one file is processed​

The short version, in plain words and with an example, is on How One File Is Processed. This is the same order as a diagram.

Every file of the template goes through the same steps, in this order. The delimiters Pebble reads in step 7 are the ones your template chose with syntax, {{ }} and {% %} unless it says otherwise.


How should a file be written?​

Each file of the template is written in one of a few ways. This is the decision to make for every file, and it is what the type of a mapping entry says.


Why a file with a slot should be a seed​

An insert goes into the generated result, not into the file already on disk. A file that is an ordinary template file is written again from the template on every run, so anything typed into its slot is gone after the next generation. Make the file a seed and it is written once, so the insert updates only its own fragment from then on.

  • Without seed the second run would start from the template again, with an empty slot.
  • The text between the fragment markers belongs to the template and is replaced on the next run with the same id. Everything else in the slot is yours.
  • More: insert and Why did the text I typed into a slot disappear?

Where to read more​