plugin-icon

WP CoffeeScript

제작자: tombenner·
Allows developers to easily use CoffeeScript in WordPress. Simply use enqueue_coffeescript(); the compilation is done automatically behind the scenes.
버전
1.0
활성화된 설치 항목
10
최근 업데이트일
Jan 9, 2012

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; }
무료Business 요금제에서
설치하면 WordPress.com 서비스 약관서드파티 플러그인 약관에 동의하게 됩니다.
테스트된 버전
WordPress 3.3.2
이 플러그인은 다운로드할 수 있으며 에서 사용할 수 있습니다.