Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

onyxrev
Copy link

@onyxrev onyxrev commented Feb 19, 2013

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.

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.
@onyxrev
Copy link
Author

onyxrev commented Feb 19, 2013

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

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

@knoxknox
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants