Replace all the $ with $$ - in places other than where attr is used.
It will work