Actually can I push back a bit here? If 'undefined' doesn't get shunted in the substitution logic, then we get a wierd set of substitutions. Here's what the error from Jasmine if we don't do the shunting:

Expected '/static/f/static/r/static/o/static/m/static/ /static/v/static/i/static/s/static/u/static/a/static/l/static/ /static/e/static/d/static/i/static/t/static/o/static/r/static/' to equal 'from visual editor'.

Basically it inserts /static/ at every character of the original string. Yuck!

So I'd prefer to have a 'null/undefined' guard so that if perhaps the XModule template looses that data- field, then the "breakage" is a bit more contained. So I guess the question is whether we want things to fail silently - but reasonably gracefully - or fail quite ugly....