New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty strings not handled properly #281

Closed
daffl opened this Issue Feb 14, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@daffl
Contributor

daffl commented Feb 14, 2013

As shown in this Fiddle empty strings can cause weird behavior. A template like:

    <select>
        {{#colors}}
        <option>{{.}}</option>
        {{/colors}}
    </select>

With data like this:

new can.Observe({
    colors: ["", 'red', 'green', 'blue'],
});

Print [object Object] as the first entry.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Feb 14, 2013

Contributor

something is probably not checking for undefined / null correctly

Contributor

justinbmeyer commented Feb 14, 2013

something is probably not checking for undefined / null correctly

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Feb 14, 2013

Contributor

Yes, I think it's a truthyness thing, too. Another question might be if empty strings should be truthy.
Should {{#name}}Your name: {{.}}{{/name}} be evaluated if name is an empty string?

Contributor

daffl commented Feb 14, 2013

Yes, I think it's a truthyness thing, too. Another question might be if empty strings should be truthy.
Should {{#name}}Your name: {{.}}{{/name}} be evaluated if name is an empty string?

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Feb 14, 2013

Contributor

I bet that behavior is specified by Mustache

Contributor

justinbmeyer commented Feb 14, 2013

I bet that behavior is specified by Mustache

@ghost ghost assigned andykant Mar 13, 2013

andykant added a commit that referenced this issue Mar 21, 2013

andykant added a commit that referenced this issue Mar 21, 2013

Merge pull request #328 from bitovi/empty-string-array-281
Mustache: Pass raw array data as the context instead of trying to resolve it #281

@andykant andykant closed this Mar 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment