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
  0a22351a_c237_f9ca_df3f_a6e82bad69d8["parseText()"]
  cb40d1fd_2ff1_986b_17b9_664308ced21f["resolveTemplateUsageCheckString()"]
  cb40d1fd_2ff1_986b_17b9_664308ced21f -->|calls| 0a22351a_c237_f9ca_df3f_a6e82bad69d8
  c27f0203_4eed_0348_4118_e8e105adc6ee["parse()"]
  c27f0203_4eed_0348_4118_e8e105adc6ee -->|calls| 0a22351a_c237_f9ca_df3f_a6e82bad69d8
  6f72c0fc_c9ca_496b_1bc7_d93b516eda63["processAttrs()"]
  6f72c0fc_c9ca_496b_1bc7_d93b516eda63 -->|calls| 0a22351a_c237_f9ca_df3f_a6e82bad69d8
  2e7c25ee_983d_edd1_399c_2f07c7c41ac8["transformNode()"]
  2e7c25ee_983d_edd1_399c_2f07c7c41ac8 -->|calls| 0a22351a_c237_f9ca_df3f_a6e82bad69d8
  6ff8ece7_aa25_0786_1ca4_98f18f60c01c["transformNode()"]
  6ff8ece7_aa25_0786_1ca4_98f18f60c01c -->|calls| 0a22351a_c237_f9ca_df3f_a6e82bad69d8
  aec33ae8_4a31_c2da_b1a7_10a8631fd10f["buildRegex()"]
  0a22351a_c237_f9ca_df3f_a6e82bad69d8 -->|calls| aec33ae8_4a31_c2da_b1a7_10a8631fd10f
  e82e0ef9_225b_c510_670f_d4553c00a84c["parseFilters()"]
  0a22351a_c237_f9ca_df3f_a6e82bad69d8 -->|calls| e82e0ef9_225b_c510_670f_d4553c00a84c
  style 0a22351a_c237_f9ca_df3f_a6e82bad69d8 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
  }
}

Subdomains

Frequently Asked Questions

What does parseText() do?
parseText() is a function in the vue codebase.
What does parseText() call?
parseText() calls 2 function(s): buildRegex, parseFilters.
What calls parseText()?
parseText() is called by 5 function(s): parse, processAttrs, resolveTemplateUsageCheckString, transformNode, transformNode.

Analyze Your Own Codebase

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

Try Supermodel Free