Download the PHP package frozzare/digster without Composer
On this page you can find all versions of the php package frozzare/digster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download frozzare/digster
More information about frozzare/digster
Files in frozzare/digster
Package digster
Short Description Twig templates for WordPress
License MIT
Homepage https://github.com/frozzare/wp-digster
Informations about the package digster
Digster
Twig templates for WordPress
Digster it's a WordPress plugin that allows you to render Twig views with a few Twig globals.
It's easy to register your own composers.
Install
Example
Example of page.php
Example of page.twig
Configuration
Digster has a few WordPress filters, one is the config filter. Debug is turn on by default if WP_ENV
equals development
Locations
A array with the locations of the views. By default
the get_templates_directory() . '/views'
is registered.
Twig environment options
Read about the options on the Twig site
auto_reload
example
API functions
All functions that has digster_
prefix can also be called as a static method on \Frozzare\Digster\Digster
class. Just replace digster_
with Digster::
, make sure that you have in your code use Frozzare\Digster\Digster
Fetch view
Fetch the view in to a string.
Get the view instance
Every view in digster is a instance of the view class and this can be accessed.
Nested views
digster_view
or view
will return the view instance so you can use the nest
method.
You can do the same with digster_render
and digster_fetch
Register composer
With Digster you can register composer with wildcard template or a specified template.
This example is for post
object, but Digster already have this global variable loaded.
You can also create a composer class that you can add with digster_composer
. The only method that is required on a composer class is compose
that takes a view argument.
Register custom filters
Since 1.7.1
Register custom functions
Since 1.7.1
Register custom globals
Since 1.7.1
Register extension
Register Twig extension classes with Digster.
Render a view
Render a view
Share data between views
You can either use digster_composer
with *
(wildcard) to share data between views or use digster_share
. All shared that can be overwrite.
Twig filters
apply_filters
Apply filters to Twig output.
Excerpt
Get the post summary
Shortcodes
Run WordPress shortcodes on the text
wpautop
Append p tags to the text
Twig functions
Since 1.7.1
you can call esc_html__
, esc_html_e
, esc_attr__
, esc_attr_e
, esc_js
, esc_textarea
, esc_url
and esc_url_raw
with the same arguments as you should use in WordPress.
Call __
The same argument as WordPress's __.
Digster has full support for Twig i18n, read more about it.
Call _n
The same argument as WordPress's _n.
Digster has full support for Twig i18n, read more about it.
Call action
You can send more arguments to do action
Call apply_filters
Takes the same arguments as apply_filters
Call body_class
Call language_attributes
Call random function
You can send in more arguments to fn
Call wp_footer
Call wp_head
Call wp_title
Takes the same arguments as wp_title
Twig globals
post
post
is global when get_the_ID()
returns a id.
Twig i18n
Digster has full support for Twig i18n extensions. You don't have to do anything to enable it, just use it! It will load the theme text domain automatic. Don't forget to add it to your style.css
.
Using Poedit? You should look at Twig Gettext Extractor! Digster will install Twig Gettext Extractor so you don't have to do it!
Cache
Look at Twig cache extension (Digster installs the package so you don't have to install it). Digster has a build in cache provider that uses the WordPress Object cache.
Coding style
You can check if your contribution passes the styleguide by installing PHP CodeSniffer and running the following in your project directory:
License
MIT © Fredrik Forsmo
All versions of digster with dependencies
twig/twig Version ~1.0
asm89/twig-cache-extension Version ~1.0
frozzare/tank Version ~1.1.0
composer/installers Version ~1.0
twig/extensions Version ~1.0
umpirsky/twig-gettext-extractor Version ~1.0