vierwd / symfony-smarty
Symfony Smarty Component
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.4.0|^8.0.0
- smarty/smarty: ^3.1
- symfony/framework-bundle: 5.4.*
- symfony/process: 5.4.*
- symfony/security-bundle: 5.4.*
- symfony/templating: ^5.0.0
- symfony/webpack-encore-bundle: ^1.11
- tijsverkoyen/css-to-inline-styles: ^2.2
- twig/twig: ^2.12|^3.0
- vierwd/svg-inliner: ^1.2
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.4
- phpstan/phpstan-symfony: ^1.1
- vierwd/coding-standard: dev-master
This package is auto-updated.
Last update: 2024-10-29 05:54:14 UTC
README
Use Smarty in your templates.
Installation
Install using composer:
composer require 'vierwd/symfony-smarty'
Usage in controllers
To use smarty templates for your controller just extend the Vierwd\Symfony\Smarty\Controller\SmartyController
.
You can then use $this->render('error/error.tpl')
to render a Smarty template.
Example
// src/Controller/IndexController.php namespace App\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Vierwd\Symfony\Smarty\Controller\SmartyController; class IndexController extends SmartyController { /** * @Route("/", name="index") */ public function index(Request $request): Response { return $this->render('index/index.tpl', ['message' => 'Hello from Smarty']); } }
{* templates/index/index.tpl *} {$message}
Pre-defined variables
There are some variables, that are always available to your templates:
Pre-defined smarty functions, blocks and modifiers
- csrf_token
- integer
- url
- path
- svg
- twig
- widget
- inlineCSS
Power-Block: twig
If you still need some twig logic, you can embed twig template code within your Smarty templates:
Twig in Smarty template
{$message} {twig} {literal} {{ form_start(createForm) }} {{ form_rest(createForm) }} {/literal} {/twig}