Skip to content

Commit

Permalink
fix: handle null emits
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme de Oliveira committed Oct 26, 2022
1 parent 0fff989 commit 6ada1b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/interface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ export default defineComponent({
};
function compute() {
return props.template.replace(/{{.*?}}/g, (match) => {
const computedValue = props.template.replace(/{{.*?}}/g, (match) => {
const expression = match.slice(2, -2).trim();
return parseExpression(expression, values.value);
});
if (!computedValue) {
return null;
}
return computedValue;
}
},
});
Expand Down
4 changes: 4 additions & 0 deletions src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export function parseExpression(exp: string, values: Record<string, any>): any {
const { op, a, b } = opMatch;
const valueA = parseExpression(a, values);

if (!valueA) {
return '';
}

// unary operators
if (b === null) {
// type conversion
Expand Down

0 comments on commit 6ada1b3

Please sign in to comment.