nodejs-php-fallback/coffeescript

PHP 封装器,用于执行 coffeescript 节点包或回退到 PHP 替代方案

1.0.1 2019-01-16 14:46 UTC

This package is auto-updated.

Last update: 2024-09-16 14:44:11 UTC


README

Latest Stable Version Build Status StyleCI Test Coverage Code Climate

PHP 封装器,用于执行 coffee-script 节点包或回退到 PHP 替代方案。

用法

首先您需要 composer,如果您还没有的话。然后通过 composer require nodejs-php-fallback/coffeescript 获取包,然后在您的 PHP 文件中如果还没有的话,请要求 composer 自动加载。

<?php

use NodejsPhpFallback\CoffeeScript;

// Require the composer autload in your PHP file if it's not already.
// You do not need to if you use a framework with composer like Symfony, Laravel, etc.
require 'vendor/autoload.php';

$coffee = new CoffeeScript('path/to/my-coffee-script-file.coffee');

// Output to a file:
$coffee->write('path/to/my-js-file.js');

// Get JS contents:
$jsContents = $coffee->getResult();

// Output to the browser:
header('Content-type: text/javascript');
echo $coffee;

// You can also get Coffee-Script code from a string:
$coffee = new CoffeeScript('
alert "Foo"
');
// Then write JS with:
$coffee->write('path/to/my-js-file.js');
// or get it with:
$jsContents = $coffee->getResult();

// Pass false to the CoffeeScript constructor to wrap the rendered JS in a function, (else, the bare option is used):
$coffee = new CoffeeScript('path/to/my-coffee-script-file.coffee', false);

安全联系方式

要报告安全漏洞,请使用 Tidelift 安全联系方式。Tidelift 将协调修复和公开。