text: define(["./rivets"],function(Rivets){
  
    Rivets.TypeParser = (function() {
      function TypeParser() {}
  
      TypeParser.types = {
        primitive: 0,
        keypath: 1
      };
  
      TypeParser.parse = function(string) {
        if (/^'.*'$|^".*"$/.test(string)) {
          return {
            type: this.types.primitive,
            value: string.slice(1, -1)
          };
        } else if (string === 'true') {
          return {
            type: this.types.primitive,
            value: true
          };
        } else if (string === 'false') {
          return {
            type: this.types.primitive,
            value: false
          };
        } else if (string === 'null') {
          return {
            type: this.types.primitive,
            value: null
          };
        } else if (string === 'undefined') {
          return {
            type: this.types.primitive,
            value: void 0
          };
        } else if (string === '') {
          return {
            type: this.types.primitive,
            value: void 0
          };
        } else if (isNaN(Number(string)) === false) {
          return {
            type: this.types.primitive,
            value: Number(string)
          };
        } else {
          return {
            type: this.types.keypath,
            value: string
          };
        }
      };
  
      return TypeParser;
  
    })();
  
    Rivets.TextTemplateParser = (function() {
      function TextTemplateParser() {}
  
      TextTemplateParser.types = {
        text: 0,
        binding: 1
      };
  
      TextTemplateParser.parse = function(template, delimiters) {
        var index, lastIndex, lastToken, length, substring, tokens, value;
        tokens = [];
        length = template.length;
        index = 0;
        lastIndex = 0;
        while (lastIndex < length) {
          index = template.indexOf(delimiters[0], lastIndex);
          if (index < 0) {
            tokens.push({
              type: this.types.text,
              value: template.slice(lastIndex)
            });
            break;
          } else {
            if (index > 0 && lastIndex < index) {
              tokens.push({
                type: this.types.text,
                value: template.slice(lastIndex, index)
              });
            }
            lastIndex = index + delimiters[0].length;
            index = template.indexOf(delimiters[1], lastIndex);
            if (index < 0) {
              substring = template.slice(lastIndex - delimiters[1].length);
              lastToken = tokens[tokens.length - 1];
              if ((lastToken != null ? lastToken.type : void 0) === this.types.text) {
                lastToken.value += substring;
              } else {
                tokens.push({
                  type: this.types.text,
                  value: substring
                });
              }
              break;
            }
            value = template.slice(lastIndex, index).trim();
            tokens.push({
              type: this.types.binding,
              value: value
            });
            lastIndex = index + delimiters[1].length;
          }
        }
        return tokens;
      };
  
      return TextTemplateParser;
  
    })();
  
  
    return {
      TypeParser : Rivets.TypeParser,
      TextTemplateParser : Rivets.TextTemplateParser
    };
  
  });
  
  