sfSmarty3Plugin
1.0.0stable
for sf 1.4sf 1.3 MIT
This plugin integrates smarty 3 ([www.smarty.net][smartylink]) as a configurable view
layer into symfony.
It relies in some aspects on ideas found in sfSmartyPlugin
([www.symfony-project.org/plugins/sfSmartyPlugin][sfsmartyplugin]) but has been completely
re-written to fit the "new" [smarty 3 templating engine][smartylink].
Developers
License
Copyright (c) 2007-2010 Johannes Heinen
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sfSmart3ViewPlugin
This plugin integrates smarty 3 (www.smarty.net) as a configurable view
layer into symfony.
It relies in some aspects on ideas found in sfSmartyPlugin
(www.symfony-project.org/plugins/sfSmartyPlugin) but has been completely
re-written to fit the "new" smarty 3 templating engine.
Warning No. 1: This plugin has not yet been tested in a production environment. It
is a case study to give smarty 3 a chance, but during developement many
edge-cases occured which in my opinion proved that the smarty core has some
serious deficits in design so that is does not really fit into a
"modern web-mvc-framework" environment.
Please read this (http://nosmarty.net/) for further information about that.
Warning No. 2: Smarty 3 is not yet officially released, currently the RC 1
version of Smarty 3 is beeing tested.
Feel free to use the plugin and modify it's code in any way, improve the symfony
helper integration, write own smarty-style helpers and so on, in short: try
to have fun with smarty ;)
Smarty documentation and smarty 3 may be downloaded here: www.smarty.net
Installation
Install the plugin via symfony's build in plugin:install task or download a full
development sandbox from github (http://github.com/joshiausdemwald/sfSmarty3Plugin).
$ symfony plugin:install sfSmarty3Plugin
Configuration
The plugin is configured by an environment aware config/settings.yml and a
config/autoload.yml file which specifies the Smarty 3 library directory path.
In general you don't have to change this path unless you extract the Smarty3-files
into project_folder/lib/vendor/smarty.
To enable smarty to replace the original symfony PHP-view layer, you have to
create a module.yml configuration file in project_folder/apps/application_name/config/module.yml:
project_folder/apps/application_name/config/module.yml:
default: # For all environments
enabled: true
is_internal: false
view_class: sfSmarty
partial_view_class: sfSmarty
These few lines enable Smarty as a symfony templating engine. Note that all smarty
templates must end with ".tpl" instead of ".php", e.g. layout.php => layout.tpl,
_my_partial.php => my_partial.tpl, indexSuccess.php => indexSuccess.tpl and so on.
There is a fallback that automagically will use symfony's own sfPhpView class for
parsing templates that ends on ".php", so you are allowed to use both formats
parallel.
It is even possible to use plain php code within a smarty template by using
as a delimiter, thanks to smarty 3 "improvements" ;).
Use plugin/sfSmarty3Plugin/config/settings.yml to tweak your smarty3
configuration (respectively overwrite these settings in your
project_folder/apps/app_name/config/settings.yml). By doing so you are able
to define the default cache behaviour of smarty, for example.