PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
257 stars 49 forks source link

[QUESTION] Changing extension of templates? #227

Closed mithat closed 9 years ago

mithat commented 9 years ago

The *.html extension used by template pages is making my IDE throw a hissy fit. It's not recognizing these are Twig pages. Is there a way to change Phile's expected or allowed template page extension from *.html?

james2doyle commented 9 years ago

There isn't a "proper" way to change the template extension. But you could edit the Twig plug class.

Maybe we should add an option in the config for changing the extension to look for.

mithat commented 9 years ago

@james2doyle Thanks. I've adopted a no-core-hack workaround by creating symbolic links to template files using non-problematic file extensions. A config option would be great.

james2doyle commented 9 years ago

Nice. We have a global constant for the markdown extension. So one for templates makes sense On Fri, Apr 10, 2015 at 5:36 PM Mithat Konar notifications@github.com wrote:

@james2doyle https://github.com/james2doyle Thanks. I've adopted a no-core-hack workaround by creating symbolic links to template files using non-problematic file extensions. A config option would be great.

— Reply to this email directly or view it on GitHub https://github.com/PhileCMS/Phile/issues/227#issuecomment-91698748.

Schlaefer commented 9 years ago

This bothered me too. But it's easy to change in the upcoming 1.5. Create a new plugin:


// subclass Twig and set $tplExt
use Phile\Plugin\Phile\TemplateTwig\Template\Twig as PhileTwig;

class Twig extends PhileTwig {
    protected $tplExt = 'twig';
}

…

// set the class as template service in plugin
class Plugin extends AbstractPlugin {
    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
    public function onPluginsLoaded($data = null) {
        ServiceLocator::registerService('Phile_Template',   new Twig($this->settings));
    }
}
Schlaefer commented 9 years ago

easy to change

I contemplated about that phrase … and a plugin option is probably a better solution. ;)

PR: #229

Schlaefer commented 9 years ago

Solution: As of Phile 1.5.0 use

$config['plugins']['phile\\templateTwig']['template-extension']  = 'twig';

to set the template extension.