You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
// My Setup
OS: Win7 Pro 64bit
PHP Version: 5.6.6
Running CLI PHP server instance for local dev
I traced this issue back to the Handlebars\Loader\FilesystemLoader.php file and noticed in the getFileName() method, echoing $this->_extension shows the value is still the default ".handlebars" string instead of the shorthand I defined in my $options argument on my Handlebars instance.
<?php// My config:// ... I have a number of other config values including constant defines for VIEWS_DIRuseHandlebars\Handlebars;
$hbs = newHandlebars([
'loader' => new \Handlebars\Loader\FilesystemLoader(VIEWS_DIR)
, 'extension' => '.hbs'
, 'partials_loader' => new \Handlebars\Loader\FilesystemLoader(
VIEWS_DIR
, [
'prefix' => '_'
]
)
]);
$hbs->render($template, ['title' => 'testing']);
The text was updated successfully, but these errors were encountered:
bmcminn
changed the title
Passing 'extension' option doesn't override extension value.
Need documentation on 'extension' for file loader options
Jun 18, 2015
You cannot specify extension option at Handlebars instance and it's a correct behavior. There are several loaders and only FilesystemLoader one operates with files and needs an extension to load them. That's why extension option is only specified in FilesystemLoader constructor.
I traced this issue back to the
Handlebars\Loader\FilesystemLoader.php
file and noticed in thegetFileName()
method, echoing$this->_extension
shows the value is still the default".handlebars"
string instead of the shorthand I defined in my$options
argument on my Handlebars instance.https://github.com/XaminProject/handlebars.php/blob/master/src/Handlebars/Loader/FilesystemLoader.php#L190-L195
The end result is that Handlebars errors out saying it can't find my template because it isn't using the right file extension.
EDIT: Realized the config I setup wasn't being passed to the FilesystemLoader instance :p
I'm wanting to add a write up on the Fileloader config properties, so I'll see about getting a pull request going this weekend.
The text was updated successfully, but these errors were encountered: