<i id='QMEzg'><tr id='QMEzg'><dt id='QMEzg'><q id='QMEzg'><span id='QMEzg'><b id='QMEzg'><form id='QMEzg'><ins id='QMEzg'></ins><ul id='QMEzg'></ul><sub id='QMEzg'></sub></form><legend id='QMEzg'></legend><bdo id='QMEzg'><pre id='QMEzg'><center id='QMEzg'></center></pre></bdo></b><th id='QMEzg'></th></span></q></dt></tr></i><div id='QMEzg'><tfoot id='QMEzg'></tfoot><dl id='QMEzg'><fieldset id='QMEzg'></fieldset></dl></div>

    <small id='QMEzg'></small><noframes id='QMEzg'>

    <tfoot id='QMEzg'></tfoot>

      • <bdo id='QMEzg'></bdo><ul id='QMEzg'></ul>

        <legend id='QMEzg'><style id='QMEzg'><dir id='QMEzg'><q id='QMEzg'></q></dir></style></legend>

      1. 是否可以在 html 文件的脚本标签中编译 Coffeescript 代码?

        Is it possible to compile Coffeescript code in script tags in html files?(是否可以在 html 文件的脚本标签中编译 Coffeescript 代码?)

            <legend id='Wq2OS'><style id='Wq2OS'><dir id='Wq2OS'><q id='Wq2OS'></q></dir></style></legend>

                  <tbody id='Wq2OS'></tbody>

                <small id='Wq2OS'></small><noframes id='Wq2OS'>

                <i id='Wq2OS'><tr id='Wq2OS'><dt id='Wq2OS'><q id='Wq2OS'><span id='Wq2OS'><b id='Wq2OS'><form id='Wq2OS'><ins id='Wq2OS'></ins><ul id='Wq2OS'></ul><sub id='Wq2OS'></sub></form><legend id='Wq2OS'></legend><bdo id='Wq2OS'><pre id='Wq2OS'><center id='Wq2OS'></center></pre></bdo></b><th id='Wq2OS'></th></span></q></dt></tr></i><div id='Wq2OS'><tfoot id='Wq2OS'></tfoot><dl id='Wq2OS'><fieldset id='Wq2OS'></fieldset></dl></div>
                <tfoot id='Wq2OS'></tfoot>
                • <bdo id='Wq2OS'></bdo><ul id='Wq2OS'></ul>

                  本文介绍了是否可以在 html 文件的脚本标签中编译 Coffeescript 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  有吗一种将 CoffeeScript 发送到客户端浏览器并将其编译为 JavaScript 的方法那里?

                  有没有一种简单的方法来编译 html 中的 <script> 标签内的 Coffeescript,或者您通常将所有 Coffeescript 放在单独的文件中?

                  Is there a simple way to compile Coffeescript that is inside <script> tags inside html, or do you usually have all Coffeescript in separate files?

                  推荐答案

                  回应dvcolgan的澄清评论:

                  Responding to dvcolgan's clarifying comment:

                  因此,您希望在服务器上有一个带有内联 CoffeeScript 的 HTML 文件,该文件作为带有内联 JavaScript 的 HTML 提供.CoffeeScript 编译器不直接支持这一点,但您可以编写一个 Node 脚本来相当容易地做到这一点,使用 coffee-script 库和 jsdom 进行 HTML 解析.

                  So, you want to have an HTML file on the server with inline CoffeeScript that gets served as HTML with inline JavaScript. The CoffeeScript compiler doesn't support this directly, but you could write a Node script to do it fairly easily, using the coffee-script library and jsdom to do the HTML parsing.

                  具体实现方式取决于您使用的网络框架.您可能不希望 CoffeeScript 编译器在每个请求上都运行(它非常快,但它仍然会减少服务器可以处理的每秒请求数);相反,您希望编译一次 HTML,然后从缓存中提供编译后的版本.同样,我不知道有任何现有的工具可以做到这一点,但编写自己的工具应该不会太难.

                  Exactly how you want to implement this would depend on the web framework you're using. You probably don't want the CoffeeScript compiler to run on every request (it's pretty fast, but it's still going to reduce the number of requests/second your server can handle); instead, you'd want to compile your HTML once and then serve the compiled version from a cache. Again, I don't know of any existing tools that do this, but it shouldn't be too hard to write your own.

                  这篇关于是否可以在 html 文件的脚本标签中编译 Coffeescript 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社

                      <small id='N7Hv0'></small><noframes id='N7Hv0'>

                      • <bdo id='N7Hv0'></bdo><ul id='N7Hv0'></ul>
                        <tfoot id='N7Hv0'></tfoot>

                          <tbody id='N7Hv0'></tbody>
                        <i id='N7Hv0'><tr id='N7Hv0'><dt id='N7Hv0'><q id='N7Hv0'><span id='N7Hv0'><b id='N7Hv0'><form id='N7Hv0'><ins id='N7Hv0'></ins><ul id='N7Hv0'></ul><sub id='N7Hv0'></sub></form><legend id='N7Hv0'></legend><bdo id='N7Hv0'><pre id='N7Hv0'><center id='N7Hv0'></center></pre></bdo></b><th id='N7Hv0'></th></span></q></dt></tr></i><div id='N7Hv0'><tfoot id='N7Hv0'></tfoot><dl id='N7Hv0'><fieldset id='N7Hv0'></fieldset></dl></div>

                          1. <legend id='N7Hv0'><style id='N7Hv0'><dir id='N7Hv0'><q id='N7Hv0'></q></dir></style></legend>