martingold / templater
0.2.1
2019-02-14 10:17 UTC
Requires
- latte/latte: ^2.4
- mpdf/mpdf: ^7.0
- nette/application: ^2.4
- nette/di: ^2.4
- nette/forms: ^2.4
- nette/mail: ^2.4
- nette/utils: ^2.5
- pelago/emogrifier: ^2.0
Requires (Dev)
- codeception/codeception: ^2.5
- consistence/coding-standard: ^3.5
- jakub-onderka/php-parallel-lint: ^1.0
- kahlan/kahlan: ^4.1
- martingold/coding-standard: ^0.1.2
- phpstan/phpstan: ^0.10.5
- slevomat/coding-standard: ^4.8
- tracy/tracy: ^2.5
README
Features
TemplateMailer
Service for sending mails from latte templates.
You can use CSS in header of templates or CSS file defined in configuration, because using inline CSS for each element is nasty.
$message = (new \Nette\Mail\Message()) ->setSubject('Hello!') ->setTo('test@test.tld'); $this->templateMailer->send('messageTemplate', $message, [ 'name' => 'John Doe', 'items' => ... ]);
PDF Handler
Service for generating PDF from latte templates
$pdfParams = PdfParams::from()
->setTemplateName('pdf/contract')
->setFilename('project')
->setIdentifier(96325)
->setNamespace('contract');
$this->pdfHandler->savePDF($pdfParams, $smlouva);
$templateName
is filename/path of the template without.latte
extension$filename
and$identifier
makes name of the pdf. In this example name would beproject-96325.pdf
. The identifier is required when saving the pdf to avoid overwriting older files.$namespace
is a name/path of the folder which result will be saved to
With this settings the resulting output path would be
www/downloads/pdf/contract/project-96325.pdf
Configuration
Register the extension:
extensions: templater: MartinGold\Templater\DI\TemplaterExtension
Configure extension. These are default values:
templater: templatePath: 'app/templates/' cssTemplatePath: null pdfOutputPath: 'www/downloads/pdf/'
Installation
composer require martingold/templater