MtHaml
MtHaml copied to clipboard
Update twig loader to support Twig 2.x
getSource()
was deprecated in twig 1.27
https://twig.symfony.com/doc/1.x/deprecated.html#loaders
Fixes #100 Surpasses #102
why is this one better?
getSource()
was deprecated in twig 1.27 and has been removed in twig 2.x, preventing the twig loader from working.
#102 doesn't currently perform any haml rendering in the getSourceContext()
method, it simply adds an alias method for the underlying Twig_LoaderInterface
so haml doesn't get rendered. The haml rendering needs to be performed in getSourceContext()
for twig 2.x.
I've tested with twig 2.0, though it looks like I may have broken backwards compatibility with twig 1.0 which is why the tests failed (they seem to only run for twig 1.x). I'll take a look and update the PR.
@vendethiel I've refactored the haml generation to keep support for both twig 1.x as well as making twig 2.x work, however I'm struggling to get the tests to pass across all versions.
It seems you can't mock a method if it doesn't exist, therefore:
- mocking the underlying loader's
getSource()
fails on twig 2.x - mocking the underlying loader's
getSourceContext()
fails on twig 1.x
How do you want to proceed?
@TechWilk if (method_exists(...
@jkufner yep, totally didn't think of that! I'll do some more work on it tomorrow.