Skip to content

Commit 40183d4

Browse files
author
=
committed
Update Views README for PSR-2 compliance
1 parent 19a6dfa commit 40183d4

File tree

1 file changed

+48
-62
lines changed

1 file changed

+48
-62
lines changed

Views/README.markdown

Lines changed: 48 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,86 @@
11
# Custom Views
22

3-
The Slim Framework provides a default View class that uses PHP template files by default. This folder includes custom View classes that you may use with alternative template libraries, such as [Twig](http://www.twig-project.org/), [Smarty](http://www.smarty.net/), or [Mustache](http://mustache.github.com/).
3+
The Slim Framework provides a default view class that uses PHP template files. This folder includes custom view classes
4+
that you may use with third-party template libraries, such as [Twig](http://www.twig-project.org/),
5+
[Smarty](http://www.smarty.net/), or [Mustache](http://mustache.github.com/).
46

5-
## TwigView
7+
## Twig
68

7-
The `TwigView` custom View class provides support for the [Twig](http://twig.sensiolabs.org/) template library. You can use the TwigView custom View in your Slim application like this:
9+
The `\Slim\Extras\Views\Twig` custom view class provides support for the [Twig](http://twig.sensiolabs.org/) template
10+
library. You can use the Twig custom view in your Slim Framework application like this:
811

912
<?php
10-
require 'slim/Slim.php';
11-
require 'views/TwigView.php';
12-
$app = new Slim(array(
13-
'view' => 'TwigView'
13+
$app = new \Slim\Slim(array(
14+
'view' => new \Slim\Extras\Views\Twig()
1415
));
15-
//Insert your application routes here
16-
$app->run();
17-
?>
1816

19-
You will need to configure the `TwigView::$twigOptions` and `TwigView::$twigDirectory` class variables before using the TwigView class in your application. These variables can be found at the top of the `views/TwigView.php` class definition.
17+
You will need to configure the Twig view's public `$twigOptions` and `$twigDirectory` properties. The `$twigDirectory`
18+
property is the relative or absolute path to the Twig library. The `$twigOptions` property is an array of Twig settings.
2019

21-
## MustacheView
20+
## Mustache
2221

23-
The `MustacheView` custom View class provides support for the [Mustache template language](http://mustache.github.com/) and the [Mustache.php library](github.com/bobthecow/mustache.php). You can use the MustacheView custom View in your Slim application like this:
22+
The `\Slim\Extras\Views\Mustache` custom view class provides support for the
23+
[Mustache template language](http://mustache.github.com/) and the [Mustache.php library](github.com/bobthecow/mustache.php).
24+
You can use the Mustache custom view in your Slim Framework application like this:
2425

2526
<?php
26-
require 'slim/Slim.php';
27-
require 'views/MustacheView.php';
28-
MustacheView::$mustacheDirectory = 'path/to/mustacheDirectory/';
29-
$app = new Slim(array(
30-
'view' => 'MustacheView'
27+
\Slim\Extras\Views\Mustache::$mustacheDirectory = 'path/to/mustacheDirectory/';
28+
$app = new \Slim\Slim(array(
29+
'view' => new \Slim\Extras\Views\Mustache()
3130
));
32-
//Insert your application routes here
33-
$app->run();
34-
?>
3531

36-
Before you can use the MustacheView class, you will need to set `MustacheView::$mustacheDirectory`. This property should be the relative or absolute path to the directory containing the `Mustache.php` library.
32+
Before you can use the Mustache view class, you must set its static public `$mustacheDirectory` property; this is the
33+
relative or absolute path to the Mustache library.
3734

3835
## SmartyView
3936

40-
The `SmartyView` custom View class provides support for the [Smarty](http://www.smarty.net/) template library. You can use the SmartyView custom View in your Slim application like this:
37+
The `\Slim\Extras\Views\Smarty` custom view class provides support for the [Smarty](http://www.smarty.net/) template
38+
library. You can use the Smarty custom view in your Slim Framework application like this:
4139

4240
<?php
43-
require 'slim/Slim.php';
44-
require 'views/SmartyView.php';
45-
$app = new Slim(array(
46-
'view' => 'SmartyView'
41+
$app = new \Slim\Slim(array(
42+
'view' => new \Slim\Extras\Views\Smarty()
4743
));
48-
//Insert your application routes here
49-
$app->run();
50-
?>
5144

52-
You will need to configure the `SmartyView::$smartyDirectory`, `SmartyView::$smartyCompileDirectory` , `SmartyView::$smartyCacheDirectory` and optionally `SmartyView::$smartyTemplatesDirectory`, class variables before using the SmartyView class in your application. These variables can be found at the top of the `views/SmartyView.php` class definition.
45+
You must configure the Smarty view's public static `$smartyDirectory`, `$smartyCompileDirectory` , `$smartyCacheDirectory`
46+
and optionally `$smartyTemplatesDirectory` properties before using the Smarty view class in your application. These
47+
properties are at the top of the `Views/Smarty.php` class definition.
5348

54-
## BlitzView
49+
## Blitz
5550

56-
The `BlitzView` custom View class provides support for the Blitz templating system for PHP. Blitz is written as C and compiled to a PHP extension. Which means it is FAST. You can learn more about Blitz at <http://alexeyrybak.com/blitz/blitz_en.html>. You can use the BlitzView custom View in your Slim application like this:
51+
The `\Slim\Extras\Views\Blitz` custom view class provides support for the Blitz templating system. Blitz is written
52+
as C and is compiled to a PHP extension. This means it is FAST. You can learn more about Blitz at
53+
<http://alexeyrybak.com/blitz/blitz_en.html>. You can use the Blitz custom view in your Slim Framework application like this:
5754

5855
<?php
59-
require 'slim/Slim.php';
60-
require 'views/BlitzView.php';
61-
$app = new Slim(array(
62-
'view' => 'BlitzView'
56+
$app = new \Slim\Slim(array(
57+
'view' => new \Slim\Extras\Views\Blitz()
6358
));
64-
//Insert your application routes here
65-
$app->run();
66-
?>
67-
68-
Place your Blitz template files in the designated templates directory.
6959

7060
## HaangaView
7161

72-
The `HaangaView` custom View class provides support for the Haanga templating system for PHP. Refer to the `views/HaangaView.php` file for further documentation.
62+
The `\Slim\Extras\Views\Haanga` custom view class provides support for the Haanga templating system. Refer to
63+
the `Views/Haanga.php` file for further documentation.
7364

7465
<?php
75-
require 'slim/Slim.php';
76-
require_once 'views/HaangaView.php';
77-
$app = new Slim(array(
78-
'view' => new HaangaView('/path/to/Haanga/dir', '/path/to/templates/dir', '/path/to/compiled/dir')
66+
$app = new \Slim\Slim(array(
67+
'view' => new \Slim\Extras\Views\Haanga(
68+
'/path/to/Haanga/dir',
69+
'/path/to/templates/dir',
70+
'/path/to/compiled/dir'
71+
)
7972
));
80-
//Insert your application routes here
81-
$app->run();
82-
?>
8373

84-
## H2oView
74+
## H2o
8575

86-
The `H2oView` custom View class provides support for the [H2o templating system](http://www.h2o-template.org) for PHP. You can use the H2oView custom View in your application like this:
76+
The `H2o` custom view class provides support for the [H2o templating system](http://www.h2o-template.org). You can
77+
use the H2o custom view in your Slim Framework application like this:
8778

8879
<?php
89-
require 'slim/Slim.php';
90-
require 'views/H2oView.php';
91-
92-
H2oView::$h2o_directory = './h2o/';
93-
94-
$app = new Slim(array('view' => new H2oView));
95-
// Insert your application routes here
96-
$app->run();
97-
?>
80+
\Slim\Extras\Views\H2o::$h2o_directory = './h2o/';
81+
$app = new \Slim\Slim(array(
82+
'view' => new \Slim\Extras\Views\H2oView()
83+
));
9884

99-
Refer to the `Views/H2oView.php` file for further documentation.
85+
Refer to the `Views/H2o.php` file for further documentation.
10086

0 commit comments

Comments
 (0)