Hey guys, loving using viewmodel with Blaze.
I was trying to figure out if there was a way of abstracting my often reused form fields using a sub template that accepts properties as arguments (and still maintain the bindings). Example of the code I repeat for almost all my fields (using Jade/Pug)
.form-item.half($b="class: { has-error: firstName.invalid && dirty }")
label First name
input(type="text" $b="value: firstName")
span.error($b="if: firstName.invalid && dirty, text: firstName.message")
I tried abstracting that into a reusable blaze template but the bindings don’t seem to update, eg:
+formItem label="First name" field=firstName dirty=dirty
template(name="formItem")
.form-item.half($b="class: { has-error: field.invalid && dirty }")
label {{ label }}
input(type="text" $b="value: field")
span.error($b="if: field.invalid && dirty, text: field.message")