Created
September 13, 2015 10:39
-
-
Save janit/a61b78b0a9e159fa2030 to your computer and use it in GitHub Desktop.
Twigriot 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function riotRenderer($tagName,$coords) { | |
$buffer = '<!-- begin riot: ' . $tagName . ' -->' . PHP_EOL; | |
$tagFile = '../web/js/tags/' . $tagName . '.tag'; | |
$processCommand = 'node ../renderer/app.js ' . $tagFile . ' ' . $coords[0] . ' ' . $coords[1]; | |
$process = new Process($processCommand); | |
$process->run(); | |
if (!$process->isSuccessful()) { | |
throw new \RuntimeException($process->getErrorOutput()); | |
} | |
$buffer .= $process->getOutput(); | |
$process = new Process('riot ' . $tagFile); | |
$process->run(); | |
if (!$process->isSuccessful()) { | |
throw new \RuntimeException($process->getErrorOutput()); | |
} | |
$scriptFile = trim(explode('>',$process->getOutput())[1]); | |
$buffer .= '<script src="/' . $scriptFile .'"></script>'; | |
$buffer .= PHP_EOL . '<!-- end riot -->'; | |
return $buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment