diff --git a/.editorconfig b/.editorconfig index 0d08f6e..6eeec8d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,7 +2,7 @@ root = true [*] indent_style = space -indent_size = 4 +indent_size = 2 end_of_line = lf charset = utf-8 quote_type = single diff --git a/src/index.js b/src/index.js index d2b9509..669ef9b 100644 --- a/src/index.js +++ b/src/index.js @@ -112,12 +112,18 @@ function parseLocals(options, {attrs}, html) { // Handle attributes to be merged with default // only for Array or Objects const mergeAttributeWithDefault = []; + const computedAttributes = []; Object.keys(attributes).forEach(attribute => { if (attribute.startsWith('merge:')) { const newAttributeName = attribute.replace('merge:', ''); attributes[newAttributeName] = attributes[attribute]; delete attributes[attribute]; mergeAttributeWithDefault.push(newAttributeName); + } else if (attribute.startsWith('computed:')) { + const newAttributeName = attribute.replace('computed:', ''); + attributes[newAttributeName] = attributes[attribute]; + delete attributes[attribute]; + computedAttributes.push(newAttributeName); } }); @@ -152,6 +158,8 @@ function parseLocals(options, {attrs}, html) { Object.keys(locals).forEach(local => { if (mergeAttributeWithDefault.includes(local)) { attributes[local] = merge({...locals[local]}, {...attributes[local]}); + } else if (computedAttributes.includes(local)) { + attributes[local] = locals[local]; } else if (typeof attributes[local] === 'undefined') { attributes[local] = locals[local]; }