kucherenko / silex-xsltemplate
The SilexXSLTemplate\ServiceProvider provides integration Silex microframework with the XSLTemplate template engine.
dev-master / 1.0.x-dev
2012-10-05 10:38 UTC
Requires
- php: >=5.3.2
- kucherenko/xsltemplate: >1.0-dev
- silex/silex: >1.0-dev
This package is not auto-updated.
Last update: 2025-06-21 17:08:17 UTC
README
The SilexXSLTemplate\ServiceProvider provides integration Silex microframework with the XSLTemplate template engine.
Works with PHP 5.3.2 or later.
Parameters
- xsltemplate.templates.path: Path to the directory containing xsl template files.
- xsltemplate.templates.url: HTTP url to xsl templates.
- xsltemplate.parameters (optional): An associative array of xsltemplate parameters. Check out the xsltemplate documentation for more information.
Services
- xsltemplate: The
XSLTemplate\Renderer
instance. The main way of interacting with XSLTemplate. - xsltemplate.writer: The
XSLTemplate\XML\Writer
instance. Object for collect data for template in xml format. - xsltemplate.configure: Protected closure that takes the XSLTemplate environment as an argument. You can use it to add more custom globals.
Registering
Make sure you place a copy of XSLTemplate in the vendor/xsltemplate
directory:
$app->register(new SilexXSLTemplate\ServiceProvider(), array( 'xsltemplate.templates.path' => __DIR__ . '/xsl', 'xsltemplate.templates.url' => 'xsl/', 'xsltemplate.class_path' => __DIR__ . '/vendor/xsltemplate/src', ));
Usage
The XSLTemplate provider provides a xsltemplate
service:
$app->get('/hello/{name}', function ($name) use ($app) { $app['xsltemplate.writer']->writeElement('page', 'test'); $content = $app['xsltemplate']->render('hello.xsl', $app['xsltemplate.writer']); $contentType = $app['xsltemplate']->getContentType(); return new Symfony\Component\HttpFoundation\Response( $content, 200, array('Content-Type' => $contentType) ); });
This will render a file named xsl/hello.xsl
.
For more information, check out the XSLTemplate documentation.