Home / Function/ flattenSegments() — vue Function Reference

flattenSegments() — vue Function Reference

Architecture documentation for the flattenSegments() function in codegen.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  48fb08dc_06e5_2ea9_c348_2ac656bbd173["flattenSegments()"]
  b513831f_74af_d452_c5fb_ed9ab7651ec4["genChildrenAsStringNode()"]
  b513831f_74af_d452_c5fb_ed9ab7651ec4 -->|calls| 48fb08dc_06e5_2ea9_c348_2ac656bbd173
  ea2f4f6d_abb0_6ddc_a8a6_21616cb106fa["genStringElementWithChildren()"]
  ea2f4f6d_abb0_6ddc_a8a6_21616cb106fa -->|calls| 48fb08dc_06e5_2ea9_c348_2ac656bbd173
  e2b0a9c3_7a24_c55d_154b_7d5a0a490d9b["elementToString()"]
  e2b0a9c3_7a24_c55d_154b_7d5a0a490d9b -->|calls| 48fb08dc_06e5_2ea9_c348_2ac656bbd173
  style 48fb08dc_06e5_2ea9_c348_2ac656bbd173 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/server-renderer/src/optimizing-compiler/codegen.ts lines 234–260

function flattenSegments(segments: Array<StringSegment>): string {
  const mergedSegments: string[] = []
  let textBuffer = ''

  const pushBuffer = () => {
    if (textBuffer) {
      mergedSegments.push(JSON.stringify(textBuffer))
      textBuffer = ''
    }
  }

  for (let i = 0; i < segments.length; i++) {
    const s = segments[i]
    if (s.type === RAW) {
      textBuffer += s.value
    } else if (s.type === INTERPOLATION) {
      pushBuffer()
      mergedSegments.push(`_ssrEscape(${s.value})`)
    } else if (s.type === EXPRESSION) {
      pushBuffer()
      mergedSegments.push(`(${s.value})`)
    }
  }
  pushBuffer()

  return mergedSegments.join('+')
}

Subdomains

Frequently Asked Questions

What does flattenSegments() do?
flattenSegments() is a function in the vue codebase.
What calls flattenSegments()?
flattenSegments() is called by 3 function(s): elementToString, genChildrenAsStringNode, genStringElementWithChildren.

Analyze Your Own Codebase

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

Try Supermodel Free