src/generators/template/index.js
function extendTemplateProperty(ast, sourceFile, sourceCode, sourceNode) {
  types.visit(ast, {
    visitProperty(path) {
      if (path.value.key.value === TAG_TEMPLATE_PROPERTY) {
        path.value.value = builders.functionExpression(
          null,
          [
            TEMPLATE_FN,
            EXPRESSION_TYPES,
            BINDING_TYPES,
            GET_COMPONENT_FN
          ].map(builders.identifier),
          builders.blockStatement([
            builders.returnStatement(
              callTemplateFunction(
                ...build(
                  createRootNode(sourceNode),
                  sourceFile,
                  sourceCode
                )
              )
            )
          ])
        )

        return false
      }

      this.traverse(path)
    }
  })

  return ast
}
function extendTemplateProperty(ast, sourceFile, sourceCode, sourceNode) {
  types.visit(ast, {
    visitProperty(path) {
      if (path.value.key.value === TAG_TEMPLATE_PROPERTY) {
        path.value.value = builders.functionExpression(
          null,
          [
            TEMPLATE_FN,
            EXPRESSION_TYPES,
            BINDING_TYPES,
            GET_COMPONENT_FN
          ].map(builders.identifier),
          builders.blockStatement([
            builders.returnStatement(
              callTemplateFunction(
                ...build(
                  createRootNode(sourceNode),
                  sourceFile,
                  sourceCode
                )
              )
            )
          ])
        )

        return false
      }

      this.traverse(path)
    }
  })

  return ast
}
function extendTemplateProperty ( ast , sourceFile , sourceCode , sourceNode ) { types . visit ( ast , { visitProperty ( path ) { if ( path . value . key . value === TAG_TEMPLATE_PROPERTY ) { path . value . value = builders . functionExpression ( null , [ TEMPLATE_FN , EXPRESSION_TYPES , BINDING_TYPES , GET_COMPONENT_FN ] . map ( builders . identifier ) , builders . blockStatement ( [ builders . returnStatement ( callTemplateFunction ( ... build ( createRootNode ( sourceNode ) , sourceFile , sourceCode ) ) ) ] ) ) return false } this . traverse ( path ) } } ) return ast }
Extend the AST adding the new template property containing our template call to render the component
@param   { Object } ast - current output ast
@param   { stiring } sourceFile - source file path
@param   { string } sourceCode - original source
@param   { Object } sourceNode - node generated by the riot compiler
@returns { Object } the output ast having the "template" key
Extend the AST adding the new template property containing our template call to render the component