2017 © Pedro Peláez
 

library latte-to-twig-converter

Latte to Twig converter converts Latte to Twig

image

symplify/latte-to-twig-converter

Latte to Twig converter converts Latte to Twig

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Latte to Twig Converter

Build Status Github Actions Downloads total, (*1)

Do you want to turn your Latte templates to Twig?, (*2)

Before, (*3)

{foreach $values as $key => $value}
    {$value->getName()}

    {if isset($value['position'])}
        {$value['position']|noescape}
    {else}
        {var $noPosition = true}
    {/if}
{/foreach}

After, (*4)

{% for key, value in values %}
    {{ value.getName() }}

    {% if value.position is defined %}
        {{ value.position|raw }}
    {% else %}
        {% set noPosition = true %}
    {% endif %}
{% endfor %}

And much more!, (*5)

This package won't do it all for you, but it will help you with 80 % of the boring work., (*6)

Install

composer require symplify/latte-to-twig-converter --dev

Usage

It scan all the *.twig/*.latte files and converts to Twig with *.twig., (*7)

vendor/bin/latte-to-twig-converter convert file.twig
vendor/bin/latte-to-twig-converter 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., (*8)

continueIf

-{continueIf $cond}
+{% if cond %}
-{$value}
+    {{ value }}
+{% endif %}

breakIf

-{breakIf $cond}
+{% if cond === false %}
-{$value}
+    {{ value }}
+{% endif %}

That's it :), (*9)

The Versions