import * as t from '@babel/types' ; import * as helpers from '../helpers' ; import stringPath from './stringPath' ; import { TEMPLATE_ID } from '../constants' ; export param { t . JSXExpressionContainer } element param { ( Array < string | number > ) } dataPath returns export default function JSXExpressionContainer ( element , dataPath ) { const expressionContainer = element as t . JSXExpressionContainer ; if ( t . isLiteral ( expressionContainer . expression ) ) { return `{{'${ helpers . normalizeLiteral ( ( expressionContainer . expression as t . StringLiteral ) . value ) }'}}` ; } const nodePath = stringPath ( dataPath ) ; return `<block a:if="{{${ nodePath }.children}}">
  <block a:for="{{${ nodePath }.children || []}}" key="{{item.id}}">
    <template a:if="{{item.props.${ TEMPLATE_ID }}}" is="{{'TPL_' + item.props.${ TEMPLATE_ID }}}" data="{{ node: item }}" />
    <template a:else is="{{ 'TPL_' + item.type }}" data="{{ node: item }}" />
  </block>
</block>
<template a:elif="{{${ nodePath }.props.${ TEMPLATE_ID }}}" is="{{'TPL_' + ${ nodePath }.props.${ TEMPLATE_ID }}}" data="{{ node: ${ nodePath } }}" />
<template a:else is="{{ 'TPL_' + ${ nodePath }.type }}" data="{{ node: ${ nodePath } }}" />
` ; }