Closed harikt closed 7 years ago
There are many differences in the implementation details. In Twig, you either compile a template into PHP or use the template itself to render itself. This, IMO, is a poorly (tightly) coupled design, so I opted to draw very clear lines between the components in stick.
For that reason, I ended up with:
state
in exec.go) which walks an AST and actually performs actions based on the nodes in the AST. This is actually borrowed from the Go stdlib where Execute
seems to be the idiomatic phrase for rendering a template.In this way, the Env
is simply a registry for functions, filters, etc, and actually delegates to individual instances of state
, which also means each template execution is thread-safe.
Additionally, since Go is not interpreted, "compiling" templates is more tricky. You can see a proof-of-concept I've started over in go-stickgen.
Long story short, the components and API at the core are actually quite different, but the end result is still compatible with Twig. Granted, there are still a TON of Twig Core functions, filters, tests, etc to implement before it is truly "Twig-compatible". But the Twig language itself is fully supported by stick.
Thanks for taking a look at stick! Let me know if you have any other questions. :)
Let me know if you have any other questions. :)
Not for now :) .
Thank you for your time to explain the details.
Hi @tyler-sommer ,
First I would like to thank you for your good work.
I have a question why have you opted for
Execute
rather thanRender
?Doesn't render makes api vice very close to Twig itself ?