1. Go to this page and download the library: Download surda/mjml-nette library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
surda / mjml-nette example snippets
use Surda\Mjml\MjmlTemplateFactory;
class MailSender
{
/** @var MjmlTemplateFactory */
private $mjmlTemplateFactory;
/**
* @param MjmlTemplateFactory $mjmlTemplateFactory
*/
public function __construct(MjmlTemplateFactory $mjmlTemplateFactory)
{
$this->mjmlTemplateFactory = $mjmlTemplateFactory;
}
public function sendEmail(): void
{
$template = $this->mjmlTemplateFactory->create();
$template->setFile('/path/to/template.mjml');
$template->setParameters(['foo' => 'World']);
$mail = new Message;
$mail->setHtmlBody($template);
// or
$template = $this->mjmlTemplateFactory->create();
$mail = new Message;
$mail->setHtmlBody($template->renderToString('/path/to/template.mjml', ['foo' => 'World'])));
// ...
}
}
use Surda\Mjml\Engine;
class Convertor
{
/** @var Engine */
private $engine;
/**
* @param Engine $engine
*/
public function __construct(Engine $engine)
{
$this->engine = $engine;
}
public function convert(): void
{
$mjmlFile = '/path/to/template.mjml';
$latteFile = $this->engine->renderLatteFile($mjmlFile);
// or
$mjmlFile = '/path/to/template.mjml';
$latteFile = '/path/to/template.latte';
$this->engine->renderLatteFile($mjmlFile, $latteFile);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.