\MetaLanguages
This class allows the direct inclusion of dependencies written in meta-languages, e.g. coffeescript, SASS. It is designed to automatically compile the code into their natural JS/CSS state with each page load. Special care is given to limiting this compiling process to only certain environments, e.g. dev, test.
The compiling can be forced on or off, as well, allowing the user
to use his own logic for determining a "compilable" environment.
- Author: Uncle Cheese <unclecheese@leftandmain.com>
Synopsis
class MetaLanguages
{
- // members
- public static bool $enable_compiling = true;
- protected static array $environments = ;
- public static integer $modification_tolerance = 5;
- // methods
- protected static bool should_compile()
- public static void __callStatic()
- public static void set_compile_environments()
- public static array run_command()
- public static bool within_modification_tolerance()
Tasks
Line | Task |
---|---|
20+ | The true SASS compiler cannot be run from within PHP very easily because it is a Ruby gem, and raises all sorts of environment issues when running shell_exec(). Instead, this class uses a thirdparty PHP class that compiles SASS which is known to have some bugs. |
Members
Methods
protected
- should_compile() — Determines whether this environment should compile meta-languages
public
- __callStatic()
- run_command() — Runs a shell command and uses proc_open to keep a careful watch on the output. More reliable than shell_exec().
- set_compile_environments() — Sets the enironments that are eligible for compiling.
- within_modification_tolerance() — Compares the modified times of two files and determines if compiling should happen, based on {@link self::$modification_tolerance}. This is to limit running compiling on every request, and only run compiling scripts when changes have been made to the uncomplied file(s).