mpowaga / meteor-template-schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template Schema

Validate data context of your blaze templates and get meaningful error messages.

Simple usage

meteor add mpowaga:template-schema

<template name="post">
  <h1>{{title}}</h1>
  <p>{{content}}</p>
  <small>Likes: {{likes}}</small>
</template>

<template name="posts">
  {{#each postItem in posts}}
    {{> post postItem}}
  {{/each}}
</template>
Template.post.schema({
  title: { type: String },
  content: { type: String },
  likes: { type: Number }
});

Template.posts.helpers({
  posts() {
    return [
      {
        title: 'Hello World',
        content: 'This is my next essay...',
        likes: '10',
        author: Meteor.users.findOne()
      }
    ];
  }
});

This will produce following error in your console:

screenshot

About


Languages

Language:JavaScript 100.0%