NightlyCommit / twing

First-class Twig engine for Node.js
BSD 2-Clause "Simplified" License
199 stars 23 forks source link

Is this feature complete? #534

Closed Bilge closed 1 year ago

Bilge commented 3 years ago

Given that the list of known issues is completely empty, one might think there is nothing missing from this implementation. However, certain facets of the PHP implementation simply cannot be ported over to JavaScript land, such as const(). It seems to me, such incompatibilities should either be listed as known issues or separately in a compatibility section of the documentation. I'm very interested to know which bits are currently missing, to evaluate whether I could use this library or not with my existing templates.

ericmorand commented 3 years ago

Hi @Bilge ,

Twing is Twig@2 specification feature complete. Now, you may wonder whatTwig specification are and it is another topic that won't be solved soon enough since Twig team never took the time to write specification for the language.

Another thing to keep in mind is that TwigPHP for example comes with a lot of extensions from vendors like Symfony or Drupal. They are not part of the language specification and can be easily ported to Twing is needed - we are using internally an extension that mimics Drupal's one for example.

So, basically, all your existing templates should work but you may have to add the missing functions, filters and tags that depends on third party extensions.

Bilge commented 3 years ago

That's fine, I wouldn't expect framework extensions to be supported, just what ships with Twig. But as I mentioned, things like const() would be difficult to implement unless you added a PHP source parser. It would be nice to document which bits are missing and why.