-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to call config.plugins.plugin-name.enabled in a template because of hyphen (-) character #1957
Comments
I think I found a way around. public function onTwigSiteVariables()
{
$this->grav['twig']->disqus_comments_plugin = $this->config->get('plugins.disqus-comments');
} |
Or use twigs attribute() function. That’s what it’s for. |
Hi Andy, thanks for your reply. |
|
A big ouuf to all plugins with dashed in their name. Accessing variables via Something like return new Data((array)$this->header); Here: It could also make setting new header variables easier by accessing header.variable.set('newvalue'). However I am not exactly sure how to implement this properly, so it works correct without side effects. @rhukster should know best. |
If you are talking about Twig, it's a limitation in Twig itself. You should use the I see I just repeated myself :) |
Sure, but it seems you have fixed that for the config (original question by @diazwatson for this issue). My request was to add this functionality to the |
I don't see this change during the 1.x release. It would have too much compatibility impact. If you want to work with the hyphen easier, you can easily just convert the header array to a data object and work with it. The impact of that is minimal. I often do this in plugins when I need more flexibility that Data provides, and is a pain to work with arrays. For Grav 2.x we'll definitely do things differently. |
I am trying to get the value of
config.plugins.disqus-comments
in a twig template but I always getnull
although if I dump the content ofconfig.plugins
I can seedisqus-comments
is there.I also noticed that if I rename my plugin files and remove the
hyphen (-)
in the name, it works just fine.Is this a bug?
Is there a way to scape this character in a twig template?
I would not like to have to change my plugin name just because of that :(
Thanks
The text was updated successfully, but these errors were encountered: