sstephenson/ruby-ejs

Fails when used with Rails and given an ActiveSupport::SafeBuffer

moll opened this issue · 0 comments

moll commented

This is a mirror of a bug on Sprockets as it affects either.

The problem is this: EjsTemplate passes data to EJS.compile which uses gsub! in its implementation. When used with Rails, data is an ActiveSupport::SafeBuffer whose gsub! is messed up at the moment and breaks $1, so the EJS compiling fails.

Should EjsTemplate force data to be a regular string with to_str or should that be EJS's job to make sure the input is a regular string?

I've made a committed fix on ruby-ejs' end for now quick use. If that's the best place to convert SafeBuffers to strings, I can just make a pull request or you can pick a cherry.