symplify / latte-to-twig-converter
Latte to Twig converter converts Latte to Twig
Package info
github.com/deprecated-packages/latte-to-twig-converter-next
pkg:composer/symplify/latte-to-twig-converter
Requires
- php: >=8.0
- nette/utils: ^3.2
- symfony/console: ^5.3.x-dev
- symfony/dependency-injection: ^5.3.x-dev
- symfony/finder: ^5.3
- symfony/http-kernel: ^5.3
- symplify/symplify-kernel: ^9.4.24
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2021-08-04 10:34:42 UTC
README
Do you want to turn your Latte templates to Twig?
Before
{foreach $values as $key => $value}
{$value->getName()}
{if isset($value['position'])}
{$value['position']|noescape}
{else}
{var $noPosition = true}
{/if}
{/foreach}
After
{% for key, value in values %}
{{ value.getName() }}
{% if value.position is defined %}
{{ value.position|raw }}
{% else %}
{% set noPosition = true %}
{% endif %}
{% endfor %}
And much more!
This package won't do it all for you, but it will help you with 80 % of the boring work.
Install
composer require symplify/latte-to-twig-converter --dev
Usage
It scan all the *.twig/*.latte files and converts to Twig with *.twig.
vendor/bin/latte-to-twig convert file.twig vendor/bin/latte-to-twig convert /directory
Handle These Cases to Manually
Some code doesn't have a clear path - you have more options in Twig, so better to migrate it manually.
continueIf
-{continueIf $cond} +{% if cond %} -{$value} + {{ value }} +{% endif %}
breakIf
-{breakIf $cond} +{% if cond === false %} -{$value} + {{ value }} +{% endif %}
That's it :)
Report Issues
In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker
Contribute
The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.