const React = require('react'); const _ = require('lodash'); const cx = require('classnames'); const ErrorBar = React.createClass({ getDefaultProps : function() { return { errors : [] }; }, hasOpenError : false, hasCloseError : false, hasMatchError : false, renderErrors : function(){ this.hasOpenError = false; this.hasCloseError = false; this.hasMatchError = false; const errors = _.map(this.props.errors, (err, idx)=>{ if(err.id == 'OPEN') this.hasOpenError = true; if(err.id == 'CLOSE') this.hasCloseError = true; if(err.id == 'MISMATCH') this.hasMatchError = true; return
  • Line {err.line} : {err.text}, '{err.type}' tag
  • ; }); return ; }, renderProtip : function(){ const msg = []; if(this.hasOpenError){ msg.push(
    An unmatched opening tag means there's an opened tag that isn't closed, you need to close a tag, like this {'
    '}. Make sure to match types! ); } if(this.hasCloseError){ msg.push(
    An unmatched closing tag means you closed a tag without opening it. Either remove it, you check to where you think you opened it.
    ); } if(this.hasMatchError){ msg.push(
    A type mismatch means you closed a tag, but the last open tag was a different type.
    ); } return

    Protips!

    {msg}
    ; }, render : function(){ if(!this.props.errors.length) return null; return

    There are HTML errors in your markup

    If these aren't fixed your brew will not render properly when you print it to PDF or share it {this.renderErrors()}
    {this.renderProtip()}
    ; } }); module.exports = ErrorBar;