ruby-ejs icon indicating copy to clipboard operation
ruby-ejs copied to clipboard

Coerce null/undefined to empty string when escaping

Open emma-borhanian opened this issue 11 years ago • 3 comments

When you use escape tags with a null value it will be turned into the string "null", which can be incredibly inconvenient.

For example

value: "<%- null %>"

becomes

value: "null"

This patch changes the result to:

value: ""

This is consistent with the behavior of e.g. erb

emma-borhanian avatar Sep 26 '13 19:09 emma-borhanian

:+1: this effects my project as well, and would be a very convenient change

jfredett avatar Sep 26 '13 19:09 jfredett

Why not extract the escaping function and put it with the print one? It would be better to have one function instead of a lot of the same ones.

fxposter avatar Oct 30 '13 08:10 fxposter

I was planning on making a follow-up pull request to perform that optimization, and also apply it to the "escape_function" at the same time.

Unfortunately it looks like this project is dead.

emma-borhanian avatar Dec 22 '13 22:12 emma-borhanian