php文件中的coffeescript



是否可以在.php文件中使用coffescript,例如:

<!--test.php-->
<html>
   <head>
      <title> use coffeescript inside php file
   </head>
   <body>
       <h1>how to use coffeescript</h1>
       <p><?php echo $lorem ?></p>
       <script type="text/javascript">
          // i want to use coffeescript here 
          (function() {
              alert ('hello world')
          });
       </script>
   </body>
</html>

如果我想在我的php文件中使用coffeescript,我应该怎么做才能使它工作?

我没有理由不这样做。

https://github.com/alxlit/coffeescript-php

将您的coffee加载到var中,对其进行编译,并将生成的JS变量粘贴在<script>标记之间。

最新更新