Plugin Directory

Changeset 956248


Ignore:
Timestamp:
07/28/2014 09:30:51 PM (12 years ago)
Author:
njetskive
Message:

removed README.md and minor changes to readme.txt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • twig/trunk/readme.txt

    r956236 r956248  
    1515This WordPress plugin allows you to use the [Twig template engine](http://twig.sensiolabs.org) in your WordPress themes. It is really simple to use and even includes a template wrapper enabling you to use a master layout file to keep your themes D.R.Y.
    1616
    17 == Usage ==
     17= Usage =
    1818
    1919Let's start with the most simple use of this plugin to get you going:
     
    2424Twig::View();
    2525`
    26 And that's it! The plugin will automatically know that you are in the index.php file, and try to find the template index.twig in any of the specified template folders.
     26And that's it! The plugin will automatically know that you are in the **index.php** file, and try to find the template **index.twig** in any of the specified template folders.
    2727We will later see how we can use this principle in a very creative manner.
    2828
     
    3535]);
    3636`
    37 The plugin will now look for the template post.twig.
     37The plugin will now look for the template **post.twig**.
    3838
    39 == Template folder structure ==
     39= Template folder structure =
    4040You can offcourse keep all your templates organized into folders and render them like so:
    4141
     
    5656*If you find this an interesting aproach please read about template wrapping below.*
    5757
    58 == Passing variables to templates ==
     58= Passing variables to templates =
    5959To pass variables to our templates you pass the view function a context parameter. The context parameter is an array of variables of your choice:
    6060
     
    107107This clearly shows how we can use the WordPress template files (ex. **index.php**) to handle all our logic and let the [Twig template engine](http://twig.sensiolabs.org) do what it does best.
    108108
    109 == Remember Twig ==
     109= Remember Twig =
    110110
    111111Don't forget that you are using Twig. You can still use the awesome features of Twig such as: multiple inheritance, blocks, automatic output-escaping etc.
    112112
    113 == Template hierarchy ==
     113= Template hierarchy =
    114114
    115115This plugin utilizes WordPress template hierarchy in a very neat whay. Ex:
     
    118118`page-about-me.twig -> page-about.twig -> page.twig`. Which will be very handy when we use master layout files.
    119119
    120 == Template wrapping ==
     120= Template wrapping =
    121121
    122122The plugin comes with a simple template wrapper. It allows you to specify a master layout file: **_layout.php** and exposes two new functions:
     
    153153Because of the two new functions, if we have a file called **header-page.php** in our theme. It will be included when we visit a WordPress 'page'.
    154154
    155 == Template wrapper hierarchy ==
     155= Template wrapper hierarchy =
    156156
    157157The (second) best thing about the template wrapper is that it also follows the template hierarchy. Thus we can create the file: **_layout-page.php** and it will we used when visiting a WordPress 'page'. We can even create the file: **_layout-page-about.php** and it will be used on our about page.
Note: See TracChangeset for help on using the changeset viewer.