Skip to content
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

Handle falsy values in data. #117

Merged
merged 1 commit into from Aug 16, 2018

Conversation

thchia
Copy link
Collaborator

@thchia thchia commented Aug 13, 2018

For #116.

Problem

The templater is supposed to replace the placeholder parts of the translation string with the interpolated data. It will skip over the parts of the translation string that are not placeholders. It does this by setting a matched variable with the interpolated data, or leaving it undefined if there is no interpolation needed. Currently it fails to detect if the interpolated data is falsy (0, ""), and thus returns the literal string in the translation.

Changes

I have made it detect any data value except undefined, so you can pass 0 or an empty string in the data and have it render correctly.

@codecov
Copy link

codecov bot commented Aug 13, 2018

Codecov Report

Merging #117 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #117      +/-   ##
==========================================
+ Coverage   95.56%   95.58%   +0.01%     
==========================================
  Files           6        6              
  Lines         248      249       +1     
  Branches       75       75              
==========================================
+ Hits          237      238       +1     
  Misses         10       10              
  Partials        1        1
Impacted Files Coverage Δ
src/utils.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 322adca...fe3f5e4. Read the comment docs.

@ryandrewjohnson ryandrewjohnson merged commit ee806eb into ryandrewjohnson:master Aug 16, 2018
@ryandrewjohnson
Copy link
Owner

Looks good! Merged!

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

Successfully merging this pull request may close these issues.

None yet

2 participants