Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiopogliani authored Apr 9, 2022
1 parent 67684d4 commit c2eab35
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ This package should work anywhere where Twig is available.
```php
/** @var \Twig\Environment $twig */

use Performing\TwigComponents\Setup;
use Performing\TwigComponents\Configuration;

Setup::init($twig, '/relative/directory/to/components');
Configuration::make($twig)
->setTemplatesPath('/relative/directory/to/components')
->setTemplatesExtension('twig')
->useCustomTags()
->setup();
```

To enable the package just pass your Twig environment object to the function and specify your components folder relative to your Twig templates folder.
Expand All @@ -40,7 +44,10 @@ if (Craft::$app->request->getIsSiteRequest()) {
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function (Event $event) {
$twig = Craft::$app->getView()->getTwig();
\Performing\TwigComponents\Setup::init($twig, '/components');
\Performing\TwigComponents\Configuration::make($twig)
->setTemplatesPath('/components')
->useCustomTags()
->setup();
}
);
}
Expand Down

0 comments on commit c2eab35

Please sign in to comment.