Home / Function/ parseText() — vue Function Reference

parseText() — vue Function Reference

Architecture documentation for the parseText() function in text-parser.ts from the vue codebase.

Function typescript VueCore VDom calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  2ed64a28_b078_3038_149f_d30cf6867ba3["parseText()"]
  e3eb242c_569d_4ef6_6acd_a6d0879fa6a1["text-parser.ts"]
  2ed64a28_b078_3038_149f_d30cf6867ba3 -->|defined in| e3eb242c_569d_4ef6_6acd_a6d0879fa6a1
  19a26691_f7c4_e2d6_e9ed_59c6aff144df["parse()"]
  19a26691_f7c4_e2d6_e9ed_59c6aff144df -->|calls| 2ed64a28_b078_3038_149f_d30cf6867ba3
  89ae2d84_ca61_4847_7313_0974c1948730["processAttrs()"]
  89ae2d84_ca61_4847_7313_0974c1948730 -->|calls| 2ed64a28_b078_3038_149f_d30cf6867ba3
  8832460b_9af4_2e2a_ce8f_a437c828d7c5["buildRegex()"]
  2ed64a28_b078_3038_149f_d30cf6867ba3 -->|calls| 8832460b_9af4_2e2a_ce8f_a437c828d7c5
  b4977dfa_c8a9_400f_00e1_dac785ffde86["parseFilters()"]
  2ed64a28_b078_3038_149f_d30cf6867ba3 -->|calls| b4977dfa_c8a9_400f_00e1_dac785ffde86
  style 2ed64a28_b078_3038_149f_d30cf6867ba3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/parser/text-parser.ts lines 18–52

export function parseText(
  text: string,
  delimiters?: [string, string]
): TextParseResult | void {
  //@ts-expect-error
  const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE
  if (!tagRE.test(text)) {
    return
  }
  const tokens: string[] = []
  const rawTokens: any[] = []
  let lastIndex = (tagRE.lastIndex = 0)
  let match, index, tokenValue
  while ((match = tagRE.exec(text))) {
    index = match.index
    // push text token
    if (index > lastIndex) {
      rawTokens.push((tokenValue = text.slice(lastIndex, index)))
      tokens.push(JSON.stringify(tokenValue))
    }
    // tag token
    const exp = parseFilters(match[1].trim())
    tokens.push(`_s(${exp})`)
    rawTokens.push({ '@binding': exp })
    lastIndex = index + match[0].length
  }
  if (lastIndex < text.length) {
    rawTokens.push((tokenValue = text.slice(lastIndex)))
    tokens.push(JSON.stringify(tokenValue))
  }
  return {
    expression: tokens.join('+'),
    tokens: rawTokens
  }
}

Domain

Subdomains

Frequently Asked Questions

What does parseText() do?
parseText() is a function in the vue codebase, defined in src/compiler/parser/text-parser.ts.
Where is parseText() defined?
parseText() is defined in src/compiler/parser/text-parser.ts at line 18.
What does parseText() call?
parseText() calls 2 function(s): buildRegex, parseFilters.
What calls parseText()?
parseText() is called by 2 function(s): parse, processAttrs.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free