Vue Props Template

ginpei/vue-props-template: Write vue's props through template literal.

Examples

Basic

const pt = require('vue-props-template')
const UserItem = {
  template: '<li>{{name}} is {{age}} years old.</li>',
  props: pt`
    string name
    number age
  `
}
<ul>
  <user-item v-for="u in users" :name="u.name" :age="u.age"></user-item>
</ul>
data:  {
  users: [
    { name: 'Alice', age: 11 },
    { name: 'Bob', age: 22 },
    { name: 'Charlie', age: 'thirty-three' }
  ]
}

Charlie's age is given as string. Check dev tools and find following warning:

[Vue warn]: Invalid prop: type check failed for prop "age". Expected Number, got String.
(found in component <user-item>)