picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Support for Twig extensions? #693

Closed jsstaedtler closed 3 months ago

jsstaedtler commented 4 months ago

(Apologies in advance if I'm going through the wrong channel with this)

I've been doing a lot of theme work in Pico 3, and I've hit a situation that would be solved perfectly by Twig's u filter. But it seems that's part of an optional Twig extension, and my failed attempts at using u imply that it's not included with Pico.

I don't know how Twig is integrated into Pico, so I'm curious how big a challenge it is to add such an extension? I wish I knew more about the dev side of Pico so I could even help work that out, but I'm without a starting point on this one.

Meanwhile, thanks for this fantastic application, it's permitted me to build some great stuff so far.

PhrozenByte commented 4 months ago

You might create a Pico plugin that hooks into the onTwigRegistered event, exposing the Twig object where you can register this Twig extension. See DummyPlugin for how Pico plugins look like and refer to Twig's docs on how to register a Twig extension.

jsstaedtler commented 4 months ago

I'll give that a go, thanks!

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: