BeaconCMS/beacon

Validate existing beacon live data assign

leandrocp opened this issue · 2 comments

Currently calling @beacon_live_data with an invalid key will just return nil since that's a regular map. That's safe but easy to miss and may result on incorrect behavior.

We want to explore ways to make @beacon_live_data behave more like LV @assign and warn and/or fail to compile if such value is not existing.

Added to v0.1 since this may cause breaking changes.

My recommendation is to copy all of the keys from @beacon_live_data and whatever keys we want to expose from assign into a new assign variable prior to the template compilation. This way we limit to only what we choose to expose for template rendering. Otherwise someone could do this:

<div><%= inspect @sockert, limit: :infinity %></div>