Pugpages is a simple framework for using a pattern in wordpress websites similar to ASP.NET Razor Pages, but using open source php technologies.
Models are created using Timber.
Views are created using phug which is a derivative of the pug markup language originally created for use with JavaScript - adapted for php.
Pugpages was used with a wordpress site created with roots bedrock, though it may be used in any wordpress website with adaptation.
Your site must be using a custom wordpress theme into which you can add code that works with pugpages.
-
Add the main branch of pugpages to the repositories section of your
composer.jsonfile:"repositories": [ // Other repositories may be included earlier etc... { "type": "git", "url": "https://github.com/eavonius/pugpages" } ],
-
Add
pugpages/wordpressto your dependencies under the require section of yourcomposer.jsonfile:"require": { // Other dependencies may be included earlier etc... "pugpages/wordpress": "dev-main" }
-
Use composer to update your dependencies:
composer update
-
In the root directory of your site's theme, edit your
functions.phpfile and add the line:\PugPages\PageLoader::hook( get_stylesheet_directory(), in_array(env('WP_ENV'), ['staging', 'production']) );
NOTE: This "hooks" pugpages into your theme. The staging and production check turns off pug optimizations unless you're running in a staging or production environment so things refresh faster during development.
-
Create a
pagessubdirectory of your site's theme. This is where you'll put source code for pug vies and their corresponding page model files.
TODO