I'm currently working on a dedicated function for that, both for standard scripting and the web sources framework.