default template engine and

Notice: This thread is very old.
flexphperia
Member | 3
+
0
-

Hi Guys,

I'm completely new to Nette.

I have two questions:

1. Is it possible to not to use Latte as template engine. I would like to use regular php files.
I know how to change extension of template files by overriding formatTemplateFiles method in presenter. But how to disable Latte engine functionality (parsing it's syntax) while preserving access to variables assigned in presenter like this:

$this->template->product = 'whatever';

2. How to use ini files for app configuration instead of Neon.

Thanks for your replies :)

David Matějka
Moderator | 6445
+
+2
-

I would not recommend any of that, but it is your call.

1. Latte
First of all, you can use any php code in latte file, so you can combine the best of both worlds :) :

{$latte}
<?php any php ?>

But if you really want to drop latte support, it could be possible in these steps:

  1. implement ITemplate and ITemplateFactory (so it will replace default TemplateFactory and Template
  2. remove latte DI extension – in bootstrap after this line where you create Nette\Configurator add this:
unset($configurator->defaultExtensions['latte']);
  1. register your template factory in config, in the neon:
services:
	templateFactory: App\MyTemplateFactory
  1. as you have already figured out, override formatTemplateFiles method

2. Neon

It seems that nette already supports ini, so just change extension to ini. The issue is, ini cannot handle nested structures, so you need to write sth like this:

services.templateFactory: App\MyTemplateFactory
flexphperia
Member | 3
+
0
-

Great answer, thanks.

I'm looking in Configurator class in API Configurator.php and I cannot find where is defined defaultExtensions[‘latte’].
I'm missng something?

Last edited by flexphperia (2015-05-14 12:07)

David Matějka
Moderator | 6445
+
0
-

You are looking at old version (2.0), check the newest one (2.3): https://api.nette.org/…tor.php.html#34

flexphperia
Member | 3
+
0
-

Now I see.
Can you tell the line of code where default template factory is set or injected in Presenter or it's base classes?

David Matějka
Moderator | 6445
+
0
-

It is set in the injectPrimary method. But you don't have to worry about it. If you unregister latte extension and register your template factory in config, Nette DI will inject it automatically.