Changes to the character sheet engine

Posted by

on

in

When we introduced character sheets on the plugins library in 2020, we didn’t anticipate how big a part of the Kanka experience they would be. The first rendering engine was a disaster of a mess that constantly broke and was frustrating for artisans and users.

In 2023, we replaced it with the Blade templating engine, which Kanka uses behind the scene for every page internally too. This worked sufficiently well or several years, with some quirks and a bit of a learning curve for new developers. But from the start, many of blade’s strengths were causing us issues, mostly related to security. We knew that Blade was not a final solution, and that we’d eventually have to switch to something else.

That brings us to today, where all new plugin versions now use twig as the rendering engine. Those who have used other worldbuilding software will recognise the name, as it’s more or less a standard in the space.

We’ve also re-engineered a lot of the annoying parts of developing character sheets with this update, by organising things better.

Old Blade syntaxNew twig syntax
@if ($strength){% if properties.strength %}
@forEach ($abilities as $ability){% for ability in abilities %}
{{ $strength }}{{ properties.strength }}
{!! $text_with_html !}}{{ properties.text_with_html|raw }}
@liveAttribute(‘hp’){{ live(‘hp’) }}
@i18n(‘Hello world’){{ trans(‘Hello world’)
{{ $_entity_name }}{{ entry.name }}
{{ $_entity_type }}{{ entry.type }}
{{ $_locale }}{{ locale }}

All the entry’s properties are now in a properties object, and all the entry’s details are in an entry object. Abilities are still their own object.

The full documentation of the new syntax is available here.

What happens to existing plugins?

Plugins versions which are currently published still work using the old engine. Making a new version of an existing plugin will require using the new engine. For this, we’ve added a “best effort” auto-converter tool to help migrate the code. The form also includes a read-only view of the old html code.

auto-converter

What’s next

We hope that the new engine, whilst requiring a bit of a new learning curve, will result in fewer headaches and problems down the line, and can’t wait to see what our amazing artisans build!

Comments

Leave a comment