public VueTemplateCompilerResult compile ( String htmlTemplate ) throws VueTemplateCompilerException { ScriptObjectMirror templateCompilerResult ; try { templateCompilerResult = ( ScriptObjectMirror ) engine . invokeFunction ( "compile" , htmlTemplate ) ; } catch ( ScriptException | NoSuchMethodException e ) { e . printStackTrace ( ) ; throw new VueTemplateCompilerException ( "An error occurred while compiling the template: " + htmlTemplate + " -> " + e . getMessage ( ) ) ; } String renderFunction = ( String ) templateCompilerResult . get ( "render" ) ; String [ ] staticRenderFunctions = ( ( ScriptObjectMirror ) templateCompilerResult . get ( "staticRenderFns" ) ) . to ( String [ ] . class ) ; return new VueTemplateCompilerResult ( renderFunction , staticRenderFunctions ) ; }
Compile the given HTML template to JS functions using vue - template - compiler .