Skip to content

Instantly share code, notes, and snippets.

@janit
Created September 13, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janit/a61b78b0a9e159fa2030 to your computer and use it in GitHub Desktop.
Save janit/a61b78b0a9e159fa2030 to your computer and use it in GitHub Desktop.
Twigriot 3
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