FoilPHP / Foil

PHP template engine for native PHP templates
https://foilphp.github.io/Foil/
MIT License
170 stars 24 forks source link

Can't render double extension templates without postfix #2

Closed skyosev closed 9 years ago

skyosev commented 9 years ago
        $engine = Foil\engine([
            'ext'     => ['tpl.php'],
            'folders' => ['path/to/templates']
        ]);
        // trying to render path/to/templates/home.tpl.php
        $engine->render('home'); 

this produces

Uncaught exception 'RuntimeException': home is not a valid template name

Do I miss something or this is currently not possible with Foil ?

gmazzap commented 9 years ago

@skyosev Thanks for your interest in Foil.

In Foil ext param matches what is returned by pathinfo() as extension.

So, if a file is named home.tpl.php at the moment to render it you need

I'm agree that it can be a nice addition to Foil, I'll implement it in next release that will be released soon (0.3 branch it's already live). Thanks!

skyosev commented 9 years ago

Cool, it will be good enchantment I think.

I'm starting new ecommerce project (native php template requirements) right now and Foil seems great alternative to Plates (at first sight at least). Will watch its development closely.

gmazzap commented 9 years ago

@skyosev What I said in previous comment is completely wrong. facepalm

Foil is already capable to do that. Problem with your code is that ext must be set as string.

Real issue is in documentation, going to fix it immediately.

If you use:

        $engine = Foil\engine([
            'ext'     => 'tpl.php',
            'folders' => ['path/to/templates']
        ]);
        $engine->render('home');

it works!

gmazzap commented 9 years ago

Fixed. http://www.foilphp.it/docs/GETTING-STARTED/FILE-EXTENSIONS.html

gmazzap commented 9 years ago

In 0.3 branch I added 2 tests: unit and functional to test this feature.