Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Open
wants to merge 1 commit into from

2 participants

@onyxrev

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 onyxrev Fix for tunaries always being truthy when passed to escaping EJS tags.
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.
c82ffa6
@onyxrev

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 19, 2013
  1. @onyxrev

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

    onyxrev authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/ejs.rb
View
2  lib/ejs.rb
@@ -69,7 +69,7 @@ def js_unescape!(source)
def replace_escape_tags!(source, options)
source.gsub!(options[:escape_pattern] || escape_pattern) do
- "',(''+#{js_unescape!($1)})#{escape_function},'"
+ "',(''+(#{js_unescape!($1)}))#{escape_function},'"
end
end
Something went wrong with that request. Please try again.