MCPcopy Create free account
hub / github.com/dashnowords/imfe / parseText

Function parseText

chapter17/vue.js:9086–9119  ·  view source on GitHub ↗
(
    text,
    delimiters
  )

Source from the content-addressed store, hash-verified

9084
9085
9086 function parseText (
9087 text,
9088 delimiters
9089 ) {
9090 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
9091 if (!tagRE.test(text)) {
9092 return
9093 }
9094 var tokens = [];
9095 var rawTokens = [];
9096 var lastIndex = tagRE.lastIndex = 0;
9097 var match, index, tokenValue;
9098 while ((match = tagRE.exec(text))) {
9099 index = match.index;
9100 // push text token
9101 if (index > lastIndex) {
9102 rawTokens.push(tokenValue = text.slice(lastIndex, index));
9103 tokens.push(JSON.stringify(tokenValue));
9104 }
9105 // tag token
9106 var exp = parseFilters(match[1].trim());
9107 tokens.push(("_s(" + exp + ")"));
9108 rawTokens.push({ '@binding': exp });
9109 lastIndex = index + match[0].length;
9110 }
9111 if (lastIndex < text.length) {
9112 rawTokens.push(tokenValue = text.slice(lastIndex));
9113 tokens.push(JSON.stringify(tokenValue));
9114 }
9115 return {
9116 expression: tokens.join('+'),
9117 tokens: rawTokens
9118 }
9119 }
9120
9121 /* */
9122

Callers 4

transformNodeFunction · 0.85
transformNode$1Function · 0.85
parseFunction · 0.85
processAttrsFunction · 0.85

Calls 2

parseFiltersFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected