该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

WP CoffeeScript

描述

WP CoffeeScript is a WordPress plugin that makes enqueueing CoffeeScript as easy as enqueueing JavaScript. Instead of using wp_enqueue_script(), as you would for JS, you just use enqueue_coffeescript(), which takes almost exactly the same arguments. The only difference is that the second argument should be the file path instead of the URL. If you’d like to compile multiple CS files into a single JS file, you can use an array of file paths as the second argument.

Please note that the CoffeeScript executable must be installed on the server. You can also set a custom path to the executable (see the examples).

If you’d like to grab development releases, see what new features are being added, or browse the source code please visit the GitHub repo.

Examples

Enqueue a CoffeeScript file that’s in the theme directory:

enqueue_coffeescript('my-handle', get_template_directory().'/my-script.coffee');

Enqueue multiple CS files, compiling them into a single output file:

$script1 = get_template_directory().'/script1.coffee';
$script2 = get_template_directory().'/script2.coffee';
enqueue_coffeescript('my-handle', array($script1, $script2));

Enqueue a CS file in the footer with dependencies (the arguments are exactly the same as in wp_enqueue_script()):

enqueue_coffeescript('my-handle', get_template_directory().'/my-script.coffee', array('dep1', 'dep2'), false, true);

Set a custom path to the CS executable (the default value is coffeescript):

add_filter('wpcs_executable', 'set_wpcs_executable');
function set_wpcs_executable($path) {
    return '/my/path/to/coffeescript';
}

Compile the CS on every page load (the default behavior is to only compile when the JS has been modified):

add_filter('wpcs_caching_enabled', 'disable_wpcs_caching');
function disable_wpcs_caching($is_enabled) {
    return false;
}

安装

  1. Put wp-coffeescript into the wp-content/plugins directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Make sure that the CoffeeScript executable is installed on the server or set a custom path to the executable (see the examples)

常见问题

Where should I go for support questions or to ask for a new feature?

Please feel free to either add a topic in the WordPress forum or contact me through GitHub for any questions:

评价

此插件暂无评价。

贡献者及开发者

“WP CoffeeScript” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

将“WP CoffeeScript”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志