index.js 1.29 KB
/**
 * Created by TaoHuang on 2016/10/26.
 */


'use strict';

exports.if_cond = (left, operator, right, options) => {
    switch (operator) {
        case '==':
            return (left == right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
        case '===':
            return (left === right) ? options.fn(this) : options.inverse(this);
        case '<':
            return (left < right) ? options.fn(this) : options.inverse(this);
        case '<=':
            return (left <= right) ? options.fn(this) : options.inverse(this);
        case '>':
            return (left > right) ? options.fn(this) : options.inverse(this);
        case '>=':
            return (left >= right) ? options.fn(this) : options.inverse(this);
        case '&&':
            return (left && right) ? options.fn(this) : options.inverse(this);
        case '||':
            return (left || right) ? options.fn(this) : options.inverse(this);
        default:
            return options.inverse(this);
    }
};

exports.escapeType = (value) => {
    console.log(value);
    let strs = value.split('');
    console.log(strs);
    if (strs.length === 2) {
        strs[2] = strs[1];
        strs[1] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    }

    console.log(strs.join(''));
    return strs.join('');
};