There is a way to put ruby conditions inside javascript block? i.e.
javascript: var config = { common_value_1 : 1, common_value_2 : 2 };
In pure Slim you don't have raw nor html_safe. In those cases, simply use double curly braces as documented here:
raw
html_safe
javascript: var data = #{{ JSON.dump([{x: 1, y:2}]) }};