deved-it / grav-plugin-google-maps

Google Maps plugin for Grav
MIT License
12 stars 13 forks source link

google-maps: Minus is not a permitted character in twig variable names #19

Closed boredland closed 7 years ago

boredland commented 7 years ago

While trying to get the api-key from the config I realized, that twig does not allow a minus in a variable key. I will create a pull request soon with all mentions of google-maps replaced with googlemaps. https://github.com/twigphp/Twig/issues/277

salgua commented 7 years ago

Hi @boredland, thank you for your collaboration. As you can see here, all shortcodes in the official shortcode-ui plugin are with the minus (ui-accordion, ui-tabs...). Did you encountered some specific problem?

boredland commented 7 years ago

Sorry: i should have been more clear on this. I changed it only for consistency reasons in the shortcode-tag. The relevant part is the bare name of the plugin, when it comes to things like, in my case, the path to the plugins settings collection: Twig parses correctly:

{{ config.plugins.googlemaps.google_api_key }}

but doesn't parse:

{{ config.plugins.google-maps.google_api_key }}

salgua commented 7 years ago

There are a lot of Grav plugin (official plugin like shortcode-ui) with the minus, I cannot change the plugin name for this purpose. Why do you need to put

{{ config.plugins.googlemaps.google_api_key }}

in your twig template? Api key is automatically added by the plugin here

boredland commented 7 years ago

The thing is: I placed the template into the theme: https://github.com/Sommerregen/grav-theme-zsimplex/pull/4/commits/7b095230cb5450d88dde948516635a64c64e3a4a#diff-76fe062252b27cacb2c225b1379dcb8fR38

When I do that, of course, the MapShortcode.php isn't called and therefor none of its assets added. To add those assets via the asset-manager i need the google_api_key: https://github.com/Sommerregen/grav-theme-zsimplex/pull/4/commits/7b095230cb5450d88dde948516635a64c64e3a4a#diff-3b5d82fe3a9461f108e52412f10bd3fbR158

salgua commented 7 years ago

I'm sorry but this is a very simple shortcode plugin for Grav. It works in the same way of the official shortocde-ui plugin and it's not intended for such type of use. You are manually including the template and not using the shortcode.

boredland commented 7 years ago

But it could serve both needs, if its config-path was twig-compliant..

Am 16.05.2017 12:41 nachm. schrieb "salgua" notifications@github.com:

I'm sorry but this is a very simple shortcode plugin for Grav. It works in the same way of the official shortocde-ui plugin and it's not intended for such type of use. You are manually including the template and not using the shortcode.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/deved-it/grav-plugin-google-maps/issues/19#issuecomment-301743825, or mute the thread https://github.com/notifications/unsubscribe-auth/AEcl3BDAh_i8CqMkhGnQLoCEpov_t7rtks5r6X01gaJpZM4NcL16 .

salgua commented 7 years ago

I'm sorry, I cannot change the plugin name, it's already in the Grav directory with this name. The problem is not this plugin, but every plugin with the minus in the name. If you want to solve your problem open a ticket in an official plugin like shortcode-ui. Thanks for your collaboration.

Tofandel commented 6 years ago

@boredland Just use {{ attribute(config.plugins, 'google-maps').google_api_key }}

This is a workaround to access vars with a minus in it