I've tried countless options, but I never get the quotes to wrap around the entire value as soon as there's a space within the value string:
{% set result_string= elements
? ( "data-custom-attribute=%s"|format( elements ) )
: ''
%}
How can you make this work to get for example data-custom-attribute="this is a test"
with elements having the value 'this is a test'
?