mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Remove the use of Twig_Loader_String, added Twig::parse
This commit is contained in:
parent
dd6e0a3836
commit
bbfba7dc34
@ -1,3 +1,6 @@
|
||||
* **Build 300** (2015-10-xx)
|
||||
- Added new helper `Twig::parse` for parsing Twig.
|
||||
|
||||
* **Build 298** (2015-09-24)
|
||||
- Added the ability to use a wildcard URL parameter in CMS pages (see CMS > Pages docs).
|
||||
|
||||
|
@ -257,10 +257,10 @@ class ServiceProvider extends ModuleServiceProvider
|
||||
protected function registerTwigParser()
|
||||
{
|
||||
/*
|
||||
* Register basic Twig
|
||||
* Register system Twig environment
|
||||
*/
|
||||
App::singleton('twig', function ($app) {
|
||||
$twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]);
|
||||
App::singleton('twig.environment', function ($app) {
|
||||
$twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
|
||||
$twig->addExtension(new TwigExtension);
|
||||
return $twig;
|
||||
});
|
||||
@ -269,16 +269,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||
* Register .htm extension for Twig views
|
||||
*/
|
||||
App::make('view')->addExtension('htm', 'twig', function () {
|
||||
return new TwigEngine(App::make('twig'));
|
||||
});
|
||||
|
||||
/*
|
||||
* Register Twig that will parse strings
|
||||
*/
|
||||
App::singleton('twig.string', function ($app) {
|
||||
$twig = $app['twig'];
|
||||
$twig->setLoader(new Twig_Loader_String);
|
||||
return $twig;
|
||||
return new TwigEngine(App::make('twig.environment'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ return [
|
||||
'Str' => 'October\Rain\Support\Facades\Str',
|
||||
'Markdown' => 'October\Rain\Support\Facades\Markdown',
|
||||
'Yaml' => 'October\Rain\Support\Facades\Yaml',
|
||||
'Twig' => 'October\Rain\Support\Facades\Twig',
|
||||
'DbDongle' => 'October\Rain\Support\Facades\DbDongle',
|
||||
'Backend' => 'Backend\Facades\Backend',
|
||||
'BackendMenu' => 'Backend\Facades\BackendMenu',
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use App;
|
||||
use File;
|
||||
use Twig;
|
||||
use View;
|
||||
use Model;
|
||||
use October\Rain\Mail\MailParser;
|
||||
@ -130,17 +131,16 @@ class MailTemplate extends Model
|
||||
}
|
||||
|
||||
/*
|
||||
* Get Twig to load from a string
|
||||
* Subject
|
||||
*/
|
||||
$twig = App::make('twig.string');
|
||||
$message->subject($twig->render($template->subject, $data));
|
||||
$message->subject(Twig::parse($template->subject, $data));
|
||||
|
||||
/*
|
||||
* HTML contents
|
||||
*/
|
||||
$html = $twig->render($template->content_html, $data);
|
||||
$html = Twig::parse($template->content_html, $data);
|
||||
if ($template->layout) {
|
||||
$html = $twig->render($template->layout->content_html, [
|
||||
$html = Twig::parse($template->layout->content_html, [
|
||||
'content' => $html,
|
||||
'css' => $template->layout->content_css
|
||||
] + (array) $data);
|
||||
@ -152,9 +152,9 @@ class MailTemplate extends Model
|
||||
* Text contents
|
||||
*/
|
||||
if (strlen($template->content_text)) {
|
||||
$text = $twig->render($template->content_text, $data);
|
||||
$text = Twig::parse($template->content_text, $data);
|
||||
if ($template->layout) {
|
||||
$text = $twig->render($template->layout->content_text, [
|
||||
$text = Twig::parse($template->layout->content_text, [
|
||||
'content' => $text
|
||||
] + (array) $data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user