import { BlockStatement , JSXElement , Statement } from "@babel/types" ; import { NodePath } from "@babel/core" ; import { TagGenerator } from "../generator/generator" ; export function TranslateTemplate ( body ) { const template = body . get ( "body" ) . filter ( each => IsTemplate ( each ) ) . map ( each => each . get ( "expression" ) as NodePath < JSXElement > ) ; const translated = template . map ( each => new TagGenerator ( each ) . Generate ( ) ) ; return translated . join ( "\n" ) ; } export function IsTemplate ( statement ) { return statement . isExpressionStatement ( ) && statement . get ( "expression" ) . isJSXElement ( ) ; }