Nette Framework 2.2.0 released!

5 years ago

David Grudl
Nette Core | 6777
+
+4
-

I'd like to announce the Nette Framework 2.2.0, the biggest revolution in its history.

Nette has been split into small projects Application, Bootstrap, Caching, ComponentModel, Nette Database, DI, Finder, Forms, Http, Latte, Mail, Neon, PhpGenerator, Reflection, RobotLoader, SafeStream, Security, Tokenizer, Tracy and Nette Utils.

It also brings complete new Latte API for standalone usage:

$latte = new Latte\Engine;
$latte->setTempDirectory('/path/to/cache');
$latte->addFilter('money', function($val) { return ...; }); // formerly registerHelper()

$latte->onCompile[] = function($latte) {
    $latte->addMacro(...); // when you want add some own macros, see http://goo.gl/d5A1u2
};

$latte->render('template.latte', $parameters);
// or $html = $latte->renderToString('template.latte', $parameters);

Also Nette\Diagnostics was renamed to nice and short Tracy.

You can, as usual, download complete package or install it via Composer.

5 years ago

chemix
Bronze Partner | 905
+
+1
-

I need to say “perfect work”

5 years ago

Honza Kuchař
Backer | 1648
+
0
-

Amazing work!

4 years ago

tpr
Member | 55
+
0
-

Currently I'm experimenting with standalone Latte in a ProcessWire project and so far so good.

I would like to ask is there any way to set the default Latte template (globally), or do I need to use "{layout '@layout.latte'}" in every latte file?

4 years ago

janpecha
Member | 58
+
+2
-

@tpr Only way now is using of “fake” presenter:

<?php
class FakePresenter extends Nette\Application\UI\Presenter
{
    public function findLayoutTemplateFile()
    {
        return "/path/to/layout";
    }
}

$presenter = new FakePresenter;
$latte = new Latte\Engine;
$latte->render(..., array(
    '_control' => $presenter,
));
?>

You can use own UI\Presenter, not only from nette/application package:

<?php
namespace Nette\Application\UI;

if (!class_exists('Nette\Application\UI\Presenter')) {
    class Presenter
    {
    }
}
?>

4 years ago

tpr
Member | 55
+
0
-

Great, works fine, thanks!