cakephp / twig-view

Twig View for CakePHP
MIT License
13 stars 6 forks source link

Document issues when using View::assign/start/end #49

Open othercorey opened 4 years ago

othercorey commented 4 years ago

Users will get a confusing php error about casting to string.

Provide a better explanation for some of the porting gotchas.

markstory commented 4 years ago

Would you want this info in the readme, or should we start a docs site like some of the other plugins have?

othercorey commented 4 years ago

It would help me decide if I knew what documentation requests people have.

I don't want to re-create View documentation -- more like link to View and explain TwigView changes.

I want it to be easy to use -- but if I have to write more than very simple explanations then a separate document is probably easier.

markstory commented 4 years ago

Starting off with the README until it gets too long is a good place to start then :smile:

victoreassis commented 4 years ago

How these methods can be used avoiding this warning?

For now I created a TwigView that overrides the assign method to return nothing. I don't know if this is the way to go, but it seems to work.

othercorey commented 4 years ago

Use the do tag - https://twig.symfony.com/doc/3.x/tags/do.html

{% do _view.assign() %}

victoreassis commented 4 years ago

Thanks, it worked out great and makes a lot more sense. I should have read the docs more carefully.

The previous package didn't complain about it at all, so I though it was ok.

othercorey commented 4 years ago

The assign() function returns $this and the previous TwigView had a hack to convert itself to an empty string. It didn't throw an error, but it wasn't supposed to work like that.