Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved usage detection across includes, extends and embeds. #191

Merged
merged 2 commits into from
Apr 26, 2022

Conversation

OwlyCode
Copy link
Collaborator

@OwlyCode OwlyCode commented Dec 15, 2021

This adds support for template resolution by twigcs, allowing usage detection across multiple files.

For instance, the following files:

# child.html.twig
{{ foo }}
{% set unused_child = 1 %}
{% set foo = 1 %}
{% set unused_parent = 2 %}

{% embed 'child.html.twig' %} 

Would not mark foo as unused.

This feature is only available when using file based configuration as it requires the user to take some decisions on how to load the templates. The most simple form would be:

<?php
use FriendsOfTwig\Twigcs\TemplateResolver\NamespacedResolver;
return \FriendsOfTwig\Twigcs\Config\Config::create()
    // ...
    ->setTemplateResolver(new FileResolver(__DIR__))
    ->setRuleSet(FriendsOfTwig\Twigcs\Ruleset\Official::class)
;

@OwlyCode OwlyCode force-pushed the improved-unused-detection branch from d969716 to 64d9679 Compare December 15, 2021 12:53
@OwlyCode OwlyCode force-pushed the improved-unused-detection branch from 64d9679 to a4c7b57 Compare December 15, 2021 12:54
@OwlyCode OwlyCode force-pushed the improved-unused-detection branch from a4c7b57 to fff36a0 Compare December 15, 2021 13:43
@OwlyCode OwlyCode merged commit 3615143 into main Apr 26, 2022
@OwlyCode OwlyCode deleted the improved-unused-detection branch April 26, 2022 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants