text-parser.ts — vue Source File
Architecture documentation for text-parser.ts, a typescript file in the vue codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR e3eb242c_569d_4ef6_6acd_a6d0879fa6a1["text-parser.ts"] 452898a7_6631_766c_1752_d0d7f2ce2517["filter-parser.ts"] e3eb242c_569d_4ef6_6acd_a6d0879fa6a1 --> 452898a7_6631_766c_1752_d0d7f2ce2517 b4977dfa_c8a9_400f_00e1_dac785ffde86["parseFilters"] e3eb242c_569d_4ef6_6acd_a6d0879fa6a1 --> b4977dfa_c8a9_400f_00e1_dac785ffde86 09aa5370_2caa_6b33_3f44_6ac5211bd11b["util"] e3eb242c_569d_4ef6_6acd_a6d0879fa6a1 --> 09aa5370_2caa_6b33_3f44_6ac5211bd11b 101d3d34_ac07_228f_62b9_5d5ac4a0ea2e["index.ts"] 101d3d34_ac07_228f_62b9_5d5ac4a0ea2e --> e3eb242c_569d_4ef6_6acd_a6d0879fa6a1 style e3eb242c_569d_4ef6_6acd_a6d0879fa6a1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { cached } from 'shared/util'
import { parseFilters } from './filter-parser'
const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g
const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g
const buildRegex = cached(delimiters => {
const open = delimiters[0].replace(regexEscapeRE, '\\$&')
const close = delimiters[1].replace(regexEscapeRE, '\\$&')
return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
})
type TextParseResult = {
expression: string
tokens: Array<string | { '@binding': string }>
}
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
Functions
Types
Dependencies
Imported By
Source
Frequently Asked Questions
What does text-parser.ts do?
text-parser.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, Observer subdomain.
What functions are defined in text-parser.ts?
text-parser.ts defines 2 function(s): buildRegex, parseText.
What does text-parser.ts depend on?
text-parser.ts imports 3 module(s): filter-parser.ts, parseFilters, util.
What files import text-parser.ts?
text-parser.ts is imported by 1 file(s): index.ts.
Where is text-parser.ts in the architecture?
text-parser.ts is located at src/compiler/parser/text-parser.ts (domain: VueCore, subdomain: Observer, directory: src/compiler/parser).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free