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

Fix for turnaries always being truthy when passed to escaping EJS tags.

Open onyxrev opened this issue 12 years ago • 2 comments

The implementation was prepending an empty string blindly to the front of the fragment provided to the tags which caused the turnary to always be evaluated truthily.

Example:

<%- this.ad.activity ? this.ad.activity.activity : "" %>

...was producing:

(''+this.ad.activity ? this.ad.activity.activity : "")

... which is always truthy because of the type coercion. It now produces:

(''+(this.ad.activity ? this.ad.activity.activity : ""))

... which properly honors the intention of the evaluation.

onyxrev avatar Feb 19 '13 06:02 onyxrev

"||" operators are also broken in the current implementation and fixed with this pull request:

<%- this.value || "no value" %>

onyxrev avatar Feb 19 '13 09:02 onyxrev

@onyxrev nice job, I merged this code with #20, and add specs for it

knoxknox avatar Nov 19 '14 14:11 knoxknox