Skip to content

Commit

Permalink
Edits to the text Hari sent
Browse files Browse the repository at this point in the history
- Made capitalization of headings consistent, ensured all filenames, method
  names, and variable names were marked as code, etc.
- Name the projects with example autoloaders
- Detail both usage in global namespace as well as via import
  • Loading branch information
weierophinney committed Mar 5, 2013
1 parent 1cf1113 commit 23150fc
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Installation
============

via Composer
Via Composer
------------

1. Create a new file called composer.json and paste the following into it:
1. Create a new file called ``composer.json`` and paste the following into it:

.. code-block:: php
{
Expand All @@ -13,22 +13,24 @@ via Composer
}
}
If you already have a composer.json file, just add this line to it.
If you already have a ``composer.json`` file, just add this line to it.

2. Get composer if you don't have it on your system from
`http://getcomposer.org <http://getcomposer.org>`_

Then execute the following:

.. code-block:: bash
php composer.phar install
3. Usage

Once Composer has downloaded the component(s), all you need to do is
include the vendor/autoload.php file that was generated by Composer.
include the ``vendor/autoload.php`` file that was generated by Composer.
This file takes care of autoloading all of the libraries so that you can use them immediately:

.. code-block:: php
require_once 'pathto/vendor/autoload.php';
require_once 'path/to/vendor/autoload.php';
$mustache = new \Phly\Mustache\Mustache();
echo $mustache->render('Hello, {{name}}!', array('name' => 'Hari K T'));
Expand All @@ -45,15 +47,16 @@ Refer to the docs of the autoloader you are using.
Examples are

`Aura.Autoload <https://github.com/auraphp/Aura.Autoload>`_
`Classloader <https://github.com/symfony/Classloader>`_
`ZendLoader <https://github.com/zendframework/Component_ZendLoader>`_
`Symfony Classloader <https://github.com/symfony/Classloader>`_
`Zend Framework Loader <https://github.com/zendframework/Component_ZendLoader>`_

Built-in autoloader
-------------------

In built loader
---------------
To simplify things out of the box, the component
contains an ``_autoload.php`` file which will register an autoloader for
the ``phly_mustache`` component with ``spl_autoload``. You can simply
include that file, and start using ``Phly\Mustache``.
include that file, and start using ``phly_mustache``.

Instantiation
-------------
Expand All @@ -65,6 +68,13 @@ Usage is fairly straightforward:
include '/path/to/library/Phly/Mustache/_autoload.php';
$mustache = new Phly\Mustache\Mustache();
Alternately, import the classes and/or namespaces you will use:

.. code-block:: php
use Phly\Mustache\Mustache;
$mustache = Mustache();
Usage
=====

Expand All @@ -74,14 +84,14 @@ Usage
By default, ``phly_mustache`` will look under the current directory for
templates ending with ``.mustache``; you can create a stack of
directories to search by using the setTemplatePath() method:
directories to search by using the ``setTemplatePath()`` method:

.. code-block:: php
$mustache->setTemplatePath($path1)
->setTemplatePath($path2);
In the above, it will search first $path2, then $path1 to resolve the template.
In the above, it will search first ``$path2``, then ``$path1`` to resolve the template.

You may also change the suffix it will use to resolve templates:

Expand Down

0 comments on commit 23150fc

Please sign in to comment.