PerlDancer / Dancer2

Perl Dancer Next Generation (rewrite of Perl Dancer)
http://perldancer.org/
Other
549 stars 274 forks source link

environment setting not available in template #650

Closed jacqueslareau closed 9 years ago

jacqueslareau commented 10 years ago

[% if settings.environment == "development" %]

Was working in Dancer1, not anymore.

simbabque commented 10 years ago

I can confirm that this is working in 0.15. Tried with Text::Xslate, not TT, but still settings.environment is definitely available.

Can probably be closed.

jacqueslareau commented 10 years ago

Just tested and still doesn't work.

xsawyerx commented 10 years ago

Having a test for it would help us resolve the conflict. :)

DavsX commented 10 years ago

https://github.com/PerlDancer/Dancer2/pull/671 My conclusion: if the environment is explicitly set in the settings or in the app (via the 'set' keyword), then the 'settings.environment' is working as it should. But if it is not set explicitly, then it returns an empty string (i quess), i.e. no default value is used.

@jacqueslareau Do you have the environment set somewhere in the config?

Should D2::C::App.pm line 498 sub _build_default_config {} include the environment?

jacqueslareau commented 10 years ago

I think I wasn't clear enough. In D1, Dancer provided the currently loaded environment without having to set it anywhere in the config. Since Dancer knows what is the environment, it was just convenient to have it available in the templates via settings.

Is it a change or a bug? It's not that big of a deal, but if it's a change, it's a breaking one and should go into the migration guide.

xsawyerx commented 9 years ago

Fixed by #808. Thanks!