Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Timber | 5,252 | 131 | 77 | a day ago | 115 | June 22, 2022 | 88 | mit | PHP | |
Create WordPress themes with beautiful OOP code and the Twig Template Engine | ||||||||||
Bolt | 4,151 | 406 | 29 | 3 months ago | 234 | June 08, 2021 | 52 | mit | PHP | |
Bolt is a simple CMS written in PHP. It is based on Silex and Symfony components, uses Twig and either SQLite, MySQL or PostgreSQL. | ||||||||||
Drupal8 Links | 288 | 6 years ago | 5 | |||||||
Drupal 8 links & resources | ||||||||||
Doctum | 229 | 2 | a month ago | 14 | January 09, 2022 | 11 | mit | PHP | ||
A php API documentation generator, fork of Sami | ||||||||||
Silverstripe Installer | 164 | 6 | 2 | a month ago | 265 | February 09, 2023 | 7 | bsd-3-clause | Twig | |
The installer for Silverstripe CMS and Framework. Check out this repository to start working with Silverstripe! | ||||||||||
Sprig | 128 | 7 years ago | 6 | PHP | ||||||
Sprig is a WordPress Starter Theme that features the Twig Templating Engine | ||||||||||
Simplethingsformextrabundle | 104 | 10 | 7 years ago | 4 | April 17, 2014 | 6 | PHP | |||
[DEPRECATED] | ||||||||||
Sage Twig Theme | 95 | 7 years ago | 3 | mit | JavaScript | |||||
Best of Sage and Twig in one Theme | ||||||||||
Emulsify Drupal | 80 | 1 | 2 months ago | 24 | September 09, 2022 | 16 | gpl-2.0 | JavaScript | ||
Drupal theme built with Storybook and Webpack | ||||||||||
Meadow | 72 | 4 | 1 | 4 years ago | 3 | December 31, 2018 | mit | PHP | ||
WordPress templating DSL based on Twig. |
Create themes quicker and easier then ever before with the incredible power of Twig's PHP Templating Engine. Built off of underscore, Roots, and Twigpress, Sprig has tons of functions and useful WordPress features essential to any theme.
By default Sprig comes with Bootstrap, looking for the Foundation version? It's right here!
Special Thanks to Mike Shaw, the Team at Roots, and the creators of underscore for making the Twigpress WordPress Plugin, the Roots Starter Theme and the _s Theme respectively.
git clone [email protected]:zach-adams/sprig.git
or download the zip file and install it like a normal WordPress theme.sudo npm install
or npm install
bower install
to install dependenciesgulp dev
to compile the initial css and js or just gulp
to compile initial css and js and then run watch taskgulp build
when you're ready for your assets to be concatinated and minifiedTwig is a flexible, fast, and secure template engine for PHP. It allows developers to write and structure their themes quickly and understandably.
Here's the WordPress loop in Twig:
{% for post in posts() %} {{ the_post(post) }}
<a href="{{ wp.the_permalink }}">{{ wp.the_title }}</a>
{% endfor %}
Twig is loaded in the theme functions in the twigpress.php file in the inc/ directory. After it has been loaded the function twigpress_render_twig_template
is available for us to use. If we look at all the top-level theme files you'll notice all they have in theme is that function. What that function does is tell WordPress to look into the twigs/ directory and find the equivalent filename except with .twig as an extension. It then tells WordPress that Twig will handle the rendering of this file.
You call functions like normal except with wp
prepended to them like (wp.the_title) due to reasons explained in Caveats section. Functions can be called like normal:
wp.comment_form_title('Leave a Reply', 'Leave a Reply to')
Or simply:
wp.comment_form_title
If you need to give it an array as an argument you can like so:
wp.get_comments({'post_id':wp.get_the_ID,'status':'approve'})
This equates to
$args = array(
'post_id' => get_the_ID(),
'status' => 'approve'
);
get_comments($args);
Note: Twig can not instantiate objects. So I made a function to do it for you. You can make an object like so:
wp.returnObject('sprig_Walker_Comment')
{{ wp.wp_list_comments({'walker':wp.returnObject('sprig_Walker_Comment')}, comments) }}
You can access the WordPress loop with the posts()
function. The posts()
function without any arguments will return the original WordPress loop. Instead of using the_post()
like normal you need to pass in the post object so it will setup correctly.
{% for post in posts() %} {{ the_post(post) }}
{{ wp.the_title }}
{% endfor %}
Instead of using an empty posts
function you can pass in arguments like you would with WP_Query.
{% for post in posts({
'orderby':'name',
'order':'ASC'}) %} {{ the_post(post) }}
{% include 'content/content-excerpt.twig' %}
{% endfor %}
You can get Repeater loops like this:
{% for row in wp.get_field('images') %}
<h1>{{ row.title }}</h1>
{{ wp.wp_get_attachment_image(row.image, 'full') }}
{% endfor %}
There's always a catch. There are some interesting hacks I had to include in order for Twig to play nice with WordPress.
wp
which is just a wrapper for call_user_func_array
.set sidebar = dynamic_sidebar('primary') %}
)wp_query
for the wp_query global variable and posts()
function which returns all the posts necessary for the WordPress loop to work.+-- dist/ - Distribution/Production files
| +-- fonts/ - Font Files
| +-- img/ - Images (images optimized by gulp in `gulp imagemin`)
+-- inc/ - Various helpful functions and Twig code. All included in function.php
| +-- Twig/ - Twig Engine and init code
| +-- activation.php - Code to run on theme activation
| +-- comments.php - Custom comments walker optimized for Bootstrap
| +-- config.php - Theme configuration options
| +-- extras.php - Some extra functions and important Twig WordPress helper functions
| +-- gallery.php - Cleans up the gallery shortcode and optimizes it for Bootstrap
| +-- init.php - Code to run on theme init
| +-- scripts.php - Scripts queueing
| +-- titles.php - Better titles function (Thanks to _s!)
| +-- twigpress.php - Loader for the Twig Engine
| +-- utils.php - Utility functions
| +-- wp_bootstrap_navwalker.php - Navwalker optimized for Bootstrap
+-- src/ - Development Files
| +-- js/ - Javascript files
| +-- sass/ - Default SASS directory
| | +-- base/ - Basic CSS styles for HTML, Typography, Colors, etc.
| | +-- components/ - WordPress Specific code, tables, buttons, etc.
| | +-- helpers/ - SASS helpers, variables, mixins, paths
| | +-- layout/ - Header, Footer, Navigation, Site, etc.
| | +-- pages/ - Page specific code (home, contact, etc.)
+-- vendor/ - Vendor files, bower installs here
+-- twigs/ - Twig templates go here
| +-- content/ - Main content for the templates
| +-- includes/ - Various includes
| +-- layouts/ - Fundamental layouts of the templates
Install Gulp with npm install -g gulp
and Bower with npm install -g bower
gulp dev
- Compiles SASS (without minification), concatinates CSS included with Bower (read in Bower section), copies main.jsgulp build
- Compiles SASS (with minifcation), concatinates and minifies CSS included with Bower (read in Bower section), copies main.jsgulp watch
- Watches src/ and dist/ folders for changes (as well as all PHP and Twig files) and triggers livereload when it detects onegulp imagemin
- Minifies images in /dist/imggulp
- Runs gulp dev
then gulp watch
Read more about bower here. Bower installs to the vendor/ directory.
Gulp has a plugin called main-bower-files that can read the main files in each bower install, determining which one you're looking for from that. Most of it should happen automatically as you install Bower packages, however there may be times where you don't want packages included in the vendor.css or vendor.js or you wish to alter the files that are included by default. Here's how to do that.
{
"overrides": {
"BOWER-PACKAGE-NAME-GOES-HERE": {
"main": "**/*.js",
ignore": true
}
}
}
This theme comes with the Bootstrap Nav Walker developed by twittem. Reference the Github page on how to make changes.
That's just about it! Let me know if you have any questions and I'll be sure to answer them! [email protected]
WARNING: This is not even close to being in a stable place, I would highly not recommend using this in production yet as there are probably a lot of bugs I haven't found yet.