wanze / TemplateEngineTwig

A ProcessWire module adding Twig templates to the TemplateEngineFactory.
MIT License
12 stars 11 forks source link

filter trim is broken #18

Closed aagd closed 5 years ago

aagd commented 5 years ago

After upgrading TemplateEngineTwig from 1.0.4 to 1.1.0 i get a problem with {% filter trim %}{% endfilter %}. Instead of trimming the string, i get another unrelated string (Page Title) as a replacement. Removing the filter, I get back the expected untrimmed string.

PHP 7.1.12, ProcessWire 3.0.98, Cache Folder cleared

wanze commented 5 years ago

Hi @aagd

Where is that filter coming from? Is it included in Twig? The only trim filter I know of (integrated in the base library) has a different syntax: https://twig.symfony.com/doc/1.x/filters/trim.html

Can you provide the code example?

aagd commented 5 years ago

Hi @wanze

The Filter tag is part of Twig 1 & 2: https://twig.symfony.com/doc/2.x/tags/filter.html It should work with all twig filters to apply them to a block of template data. It was working fine in 1.0.4.

wanze commented 5 years ago

Thanks for the links, I didn't know that one :)

This is really strange, 1.1.0 did basically just update Twig to 1.35.2. I suspect ProcessWire's file compiler, which should not be enabled for compiled twig templates. Can you try the following?

If none of this works, I would need code in order to reproduce and debug the problem.

aagd commented 5 years ago

Hi @wanze i just read in the 2.0 Readme that the updates need to be done via composer. If I remember correctly, I upgraded via the PW Upgrade Module. It somehow worked, but I can't reproduce to Upgrade anymore – errors, white screen all over the place. So this was probably the cause. This Readme note is a bit hard to find there. After building PW sites for some years now, i never came across a module that required composer for upgrades, so maybe this should be more visible, or somehow not upgradeable via the Upgrade Module (New Name?). I'll try the composer upgrade another time. Many thanks for now! AA

wanze commented 5 years ago

Hi @aagd

Composer is needed to manage the Twig dependencies. Having these bundled in the module leads to problems if other modules try to include Twig, or rely on a specific version of Twig. Composer solves these problems. However, now I have the problem that I cannot separate the 2 versions in the modules directory. For example, I would like to only have v1.1.0 listed in the directory. But it automatically parses the 2.x version on the master branch.

How did you upgrade? Because the download link should point to the 1.1.0 version, not the 2.0 one. You can check the link here: https://modules.processwire.com/modules/template-engine-twig/ If the upgrade module always picks the latest master, it looks like I have no choice but to remove the module from the directory.

aagd commented 5 years ago

Hi @wanze,

I'm sorry, I might have confused version numbers between Template Engine Factory and Template Engine Twig.

That site currently runs:

wanze commented 5 years ago

Hi @aagd,

Any updates on this issue, did you try my suggestions to resolve it?

Cheers

aagd commented 5 years ago

Hi @wanze, sorry, I only restored the previous versions to get things going again. Thanks for your suggestions, I might try them next time, if I'm going to work on that site again...

wanze commented 5 years ago

I'm going to close this, feel free to reopen if the issue pops up again.