MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / stringifyVueComponent

Function stringifyVueComponent

packages/extension/utils/component.ts:325–362  ·  view source on GitHub ↗
(
  component: DevComponent,
  indentLevel = 0,
  isInline?: (tag: string) => boolean
)

Source from the content-addressed store, hash-verified

323}
324
325function stringifyVueComponent(
326 component: DevComponent,
327 indentLevel = 0,
328 isInline?: (tag: string) => boolean
329) {
330 return stringifyBaseComponent(
331 component,
332 (key, value) => {
333 const eventName = getEventName(key)
334 if (eventName) {
335 const callback = typeof value === 'string' ? looseEscapeHTML(value) : '() => {}'
336 return `@${camelToKebab(eventName)}="${callback.trim()}"`
337 }
338
339 const name = key === 'className' ? 'class' : camelToKebab(key)
340
341 if (typeof value === 'string') {
342 return `${name}="${escapeHTML(value).trim()}"`
343 }
344
345 if (typeof value === 'boolean') {
346 return value ? name : `:${name}="false"`
347 }
348
349 if (typeof value === 'object' && value != null) {
350 const pruned = prune(value)
351 if (pruned == null) {
352 return ''
353 }
354 return `:${name}="${looseEscapeHTML(stringify(pruned)).trim()}"`
355 }
356
357 return `:${name}="${looseEscapeHTML(stringify(value)).trim()}"`
358 },
359 indentLevel,
360 isInline
361 )
362}
363
364function stringifyJSXComponent(
365 component: DevComponent,

Callers 1

stringifyComponentFunction · 0.85

Calls 7

looseEscapeHTMLFunction · 0.90
camelToKebabFunction · 0.90
escapeHTMLFunction · 0.90
pruneFunction · 0.90
stringifyFunction · 0.90
stringifyBaseComponentFunction · 0.85
getEventNameFunction · 0.85

Tested by

no test coverage detected