fuel / parser

Fuel PHP Framework - v1.x template parser package adapters
http://fuelphp.com
64 stars 45 forks source link

Extension for template page #29

Closed billmn closed 13 years ago

billmn commented 13 years ago

With a configuration like :

'extensions' => array(
        'php'       => 'View',
        'twig'      => array('class' => 'View_Twig', 'extension' => '.html'),
        'mustache'  => 'View_Mustache',
        'md'        => 'View_Markdown',
                ...
    ),

I expect that I can use Twig template page with ".html" extension so :

$view = \View::forge('page.twig');

that call 'views\page.html' using Twig class

But parser always search a 'page.twig' page and and if it doesn't exist I obatin a "view not found" error.

I think that the error can be in "parser\classes\view.php" in line 82 :

// Set extension when given
$extension and $view->extension = $extension;

When View class set the page extension ( .html ), the parser class has already searched and parsed the page with '.twig' extension

WanWizard commented 13 years ago

That might be a misunderstanding of what 'extension' does (and maybe the wrong choice of variable name).

If you define .html as extension, it means that

$view = \View::forge('page.html');

will use the Twig parser. It is the extension used in the forge() call, not the extension of the file on disk, which is always equal to the one used in the call.

billmn commented 13 years ago

No... if you specify an extension into an array ( in parser config file ) you can set a different extension for the forge() method and the view.

You can see an example in Parser Github documentation that using Dwoo :

// load a Dwoo template, ATTENTION: this one expects app/views/example.tpl
View::forge('example.dwoo');
WanWizard commented 13 years ago

ah, I missed that one. In that case, let's call this a bug... ;)