Well, I guess catching all the weirdness Ruby allows us to do in a single regex is a hell of a hard job. We currently have this heuristic approach which works very well for most of the sane cases. IMO, to be 100% _safe_ we'd have to actually parse the whole template as ERB/Ruby and then extract the info we want from the AST.