Skip to content

Upgrading from v2 to v3

Releases are no longer on Github

Following a slow migration to Forgejo, stencil is now migrated as well. All new releases will be published to Forgejo only.

For context on why, please see my blog post that goes into this.

⚠️ rgst-io/stencil-action users: This action will live on Github forever. To get v3, you will need to update the action to v3 which supports both Github and Forgejo targets based on the current/specified version.

Import path changed

Update any go.rgst.io/stencil/v2 import paths to go.rgst.io/stencil/v3. There is no API breaking changes in this release.

stencil create module is removed

It was replaced by stencil module create.

ApplyTemplate removed

Replaced by stencil.Include. Simply update ApplyTemplate calls to Include.

v1 block support removed

v1 blocks predate rgst-io/stencil fork and shouldn't be used by anyone outside of potentially Outreach. v2 blocks changed the syntax from

yaml
###Block(HelloWorld)
###EndBlock(HelloWorld)

to

yaml
## <<Stencil::Block(helloWorld)>>
## <</Stencil::Block>>

To migrate, update all blocks to match the new format. Note that EndBlock was replaced by an xml-esque closing tag. Again, this shouldn't impact anyone outside of potentially Outreach (they still use the old fork anyways).

module.Call scope changed

Previously, functions exported via module.Export would always be executed in the context of the defining template's scope. This was confusing from a library perspective, so the decision was made to have the functions exported default to the caller's templates scope. This is changable as needed via the 2nd parameter to module.Export "functionName" ["caller/function"], but the default was kept the same to keep compatibility. Now that we're releasing v3, it made sense to switch to the more ergonomic option.

To keep compatibility, simply add "function" to the end of module.Export calls, example:

tpl
# Before
{{ module.Export "helloWorld" }}

# After
{{ module.Export "helloWorld" "function" }}