PHPackages                             wol-soft/twig-include-dir - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. wol-soft/twig-include-dir

ActiveLibrary[Templating &amp; Views](/categories/templating)

wol-soft/twig-include-dir
=========================

Include all twig templates within a directory

2.1.0(5y ago)3731MITPHPPHP &gt;= 7.2CI failing

Since Aug 31Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/wol-soft/twig-include-dir)[ Packagist](https://packagist.org/packages/wol-soft/twig-include-dir)[ RSS](/packages/wol-soft-twig-include-dir/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/6bbcc30771e0af3583c124b575c419edefe820482b2e0c325daa27c60ffa3f2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f6c2d736f66742f747769672d696e636c7564652d6469722e737667)](https://packagist.org/packages/wol-soft/twig-include-dir)[![Minimum PHP Version](https://camo.githubusercontent.com/4c62148864d567c4ee794ffab09c1dd4a3f45e41064bbb016440beddaae71a4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e737667)](https://php.net/)[![Build Status](https://github.com/wol-soft/twig-include-dir/actions/workflows/main.yml/badge.svg)](https://github.com/wol-soft/twig-include-dir/actions/workflows/main.yml)[![Coverage Status](https://camo.githubusercontent.com/88084392b28c65afc00d9bba7c222fc9aa438152981d30341f66695c3f1f910f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f776f6c2d736f66742f747769672d696e636c7564652d6469722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/wol-soft/twig-include-dir?branch=master)[![MIT License](https://camo.githubusercontent.com/35b305b7764f88afe160be90ee2b22e1fe4caaf84aa59356fff64e35b5ed12b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776f6c2d736f66742f747769672d696e636c7564652d6469722e737667)](https://github.com/wol-soft/twig-include-dir/blob/master/LICENSE)

twig-include-dir
================

[](#twig-include-dir)

Include all twig templates within a directory

Features
--------

[](#features)

- Provide a directory with multiple .twig templates and all templates will be included
- Add *recursive* keyword to include all templates within a directory recursive
- known variable handling as known from *include* using the keywords *only* and *with*

Requirements
------------

[](#requirements)

- Requires Twig &gt;= 2.7
- Requires PHP &gt;= 7.2

Installation
------------

[](#installation)

The recommended way to install twig-include-dir is through [Composer](http://getcomposer.org):

```
$ composer require wol-soft/twig-include-dir

```

Why?
----

[](#why)

An example use case could be: you set up a site using bootstrap with many modals. Now you don't need to throw all your modals together in a file or include each modal manually but instead you can separate your modals by using one file for each modal. Throw all modals in a modal-directory and simply include the whole directory. Adding a new modal? No problem, just create a new template file in your modal-directory.

Getting started
---------------

[](#getting-started)

To use twig-include-dir you need to add the include-dir token parser to your Twig Environment first:

```
