php-gettext / Twig-Scanner

Twig code scanner for gettext
GNU General Public License v3.0
4 stars 2 forks source link

Add support for embed tags. #6

Closed tehbeard closed 3 years ago

tehbeard commented 3 years ago

This change allows the twig scanner to find gettext functions inside of {% embed ... %} tags.

main.twig

<div class="embed-wrapper">
<h2>{{ __( "string outside of embed") }}</h2>
{% embed 'embed.twig' %}
    {% block main %}
        <h3>{{ __("string inside embed") }}</h3>
        <p>...Further data to put within the embed...</p>
    {% endblock %}
{% endembed %}
</div>

embed.twig

<div class="mega-embed">
        {% block main %}
        {% endblock %}
<small>{{ __("string within the actual embed file") }}</small>
</div>

Prior to this, only __( "string outside of embed") would have been found when scanning main.twig, now __("string inside embed") will also be found.

Note: This change does not cause __("string within the actual embed file") to be found unless embed.twig is also scanned. {% embed ... %} tags are not used to find additional files.

oscarotero commented 3 years ago

Thanks, awesome work 👍 (sorry for being late)