How to transpile inline/embedded javascript using babel?

时间:2015-05-08 09:54:35

标签: babeljs

I use "babel" command to transpile ES6 script to ES5.

Ex: $(document).ready(function(){ $('#calendar').fullCalendar({ eventAfterRender: function (event, element) { var tooltip = event.title; $(element).attr("fc-title", tooltip) $(element).tooltip({ container:"body" }) } }); });

It works fine. My question is how to transpile inline javascript. For Ex: test.html

Function vbsMsgBox ()
    set sh = CreateObject("WScript.Shell")
    sh.Run "C:\Users\msiddiq1\New\PSCP.EXE -pw password username@host:/b_st/batchrepo/BS31GZI/*900000007* C:\Users\msiddiq1\New"
End Function

2 个答案:

答案 0 :(得分:4)

根据babel docs,它支持键入text/ecmascript-6text/babel的脚本。将浏览器内部版本添加到页面中,并为脚本设置正确的类型。

答案 1 :(得分:1)

您可以使用此代码并享受:)

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
<script type="text/babel">

</script>