WP Manifestindependent plugin directory

Sprig

Bare bones Twig templating support for WordPress

by Russell Heimlich · github.com/kingkool68/sprig · website

52stars
5composer installs
4forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/kingkool68/sprig/archive/refs/heads/master.zip

Also on Packagist as kingkool68/sprig:

composer require kingkool68/sprig

Declares an update source (kingkool68/sprig), so updates arrive through the plugin's own updater.

From the readme

Sprig Bare bones Twig templating support for WordPress Sprig brings the Twig templating engine to WordPress. Install the plugin and get started separating your HTML from PHP. Other Twig plugins like Timber try to bring lots of WordPress functionality into Twig. Sprig believes in separating PHP from HTML as much as possible. PHP is for gathering and massaging data and Sprig/Twig templates are for rendering HTML using the data passed to it. Keep things simple and only pass data to a template that the template needs to render. Installation 1. Clone this repo or download a zip 2. Add this to the plugin directory of your WordPress site in /wp-content/plugins/ 3. Run composer install to download the Twig template engine dependency How to Use Create a directroy in your theme called views or twig to hold your Twig template files. Render your templates using the following methods passing an array of data to be used by the template. - Sprig::render() will render a Twig template using an array of data and return it as a string - Sprig::out() will echo a rendered template - Sprig::doaction() will capture the output of a WordPress action and return a string Example example.php exam

Read the full README on GitHub →