Home / Function/ parseText() — vue Function Reference

parseText() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  dbffbbee_5e53_d952_4e1c_509b08e0b3e2["parseText()"]
  b4f4f8a4_659f_4d84_97f1_ed004d07b69d["text-parser.ts"]
  dbffbbee_5e53_d952_4e1c_509b08e0b3e2 -->|defined in| b4f4f8a4_659f_4d84_97f1_ed004d07b69d
  e259ff52_42a6_4f54_59b8_e6bf86822027["parse()"]
  e259ff52_42a6_4f54_59b8_e6bf86822027 -->|calls| dbffbbee_5e53_d952_4e1c_509b08e0b3e2
  94cd3ed6_4fec_eddb_c90a_1c38249e5b02["processAttrs()"]
  94cd3ed6_4fec_eddb_c90a_1c38249e5b02 -->|calls| dbffbbee_5e53_d952_4e1c_509b08e0b3e2
  cb4f4d3d_a4c8_4a2f_b7f1_94f8a175a0dd["buildRegex()"]
  dbffbbee_5e53_d952_4e1c_509b08e0b3e2 -->|calls| cb4f4d3d_a4c8_4a2f_b7f1_94f8a175a0dd
  b1101a58_6379_8514_36a1_9d7f75b2b23f["parseFilters()"]
  dbffbbee_5e53_d952_4e1c_509b08e0b3e2 -->|calls| b1101a58_6379_8514_36a1_9d7f75b2b23f
  style dbffbbee_5e53_d952_4e1c_509b08e0b3e2 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