diff --git a/_posts/2015-01-26-model-view-intent.md b/_posts/2015-01-26-model-view-intent.md index 6d941bb..a3ac391 100755 --- a/_posts/2015-01-26-model-view-intent.md +++ b/_posts/2015-01-26-model-view-intent.md @@ -41,11 +41,11 @@ function main(sources) { div([ div([ 'Weight ' + weight + 'kg', - input('.weight', {type: 'range', min: 40, max: 140, value: weight}) + input('.weight', {attrs: {type: 'range', min: 40, max: 140, value: weight}}) ]), div([ 'Height ' + height + 'cm', - input('.height', {type: 'range', min: 140, max: 210, value: height}) + input('.height', {attrs: {type: 'range', min: 140, max: 210, value: height}}) ]), h2('BMI is ' + bmi) ]) @@ -71,14 +71,14 @@ We have plenty of anonymous functions which could be refactored away from `main` +function renderWeightSlider(weight) { + return div([ + 'Weight ' + weight + 'kg', -+ input('.weight', {type: 'range', min: 40, max: 140, value: weight}) ++ input('.weight', {attrs: {type: 'range', min: 40, max: 140, value: weight}}) + ]); +} +function renderHeightSlider(height) { + return div([ + 'Height ' + height + 'cm', -+ input('.height', {type: 'range', min: 140, max: 210, value: height}) ++ input('.height', {attrs: {type: 'range', min: 140, max: 210, value: height}}) + ]); +} @@ -111,11 +111,11 @@ We have plenty of anonymous functions which could be refactored away from `main` div([ - div([ - 'Weight ' + weight + 'kg', -- input('.weight', {type: 'range', min: 40, max: 140, value: weight}) +- input('.weight', {attrs: {type: 'range', min: 40, max: 140, value: weight}}) - ]), - div([ - 'Height ' + height + 'cm', -- input('.height', {type: 'range', min: 140, max: 210, value: height}) +- input('.height', {attrs: }{type: 'range', min: 140, max: 210, value: height}}) - ]), + renderWeightSlider(weight), + renderHeightSlider(height),