src/Filter/Hogan.php
protected function _generateScript($file, $filename, $input)
    {
        $id = str_replace($this->_settings['ext'], '', basename($filename));
        $filepath = str_replace($this->_settings['ext'], '', $filename);

        foreach ($this->_settings['paths'] as $path) {
            $path = rtrim($path, '/') . '/';
            if (strpos($filepath, $path) === 0) {
                $filepath = str_replace($path, '', $filepath);
            }
        }

        $config = [
            'asString' => true,
        ];

        $text = <<<JS
var hogan = require('hogan.js'),
    util = require('util');

try {
    var template = hogan.compile(%s, %s);
    util.print('\\nwindow.JST["%s"] = window.JST["%s"] = ' + template + ';');
    process.exit(0);
} catch (e) {
    console.error(e);
    process.exit(1);
}
JS;
        $contents = sprintf(
            $text,
            json_encode($input),
            json_encode($config),
            $id,
            $filepath
        );
        file_put_contents($file, $contents);
    }
protected function _generateScript($file, $filename, $input)
    {
        $id = str_replace($this->_settings['ext'], '', basename($filename));
        $filepath = str_replace($this->_settings['ext'], '', $filename);

        foreach ($this->_settings['paths'] as $path) {
            $path = rtrim($path, '/') . '/';
            if (strpos($filepath, $path) === 0) {
                $filepath = str_replace($path, '', $filepath);
            }
        }

        $config = [
            'asString' => true,
        ];

        $text = <<<JS
var hogan = require('hogan.js'),
    util = require('util');

try {
    var template = hogan.compile(%s, %s);
    util.print('\\nwindow.JST["%s"] = window.JST["%s"] = ' + template + ';');
    process.exit(0);
} catch (e) {
    console.error(e);
    process.exit(1);
}
JS;
        $contents = sprintf(
            $text,
            json_encode($input),
            json_encode($config),
            $id,
            $filepath
        );
        file_put_contents($file, $contents);
    }
protected function _generateScript ( $ file , $ filename , $ input ) { $ id = str_replace ( $ this -> _settings [ 'ext' ] , '' , basename ( $ filename ) ) ; $ filepath = str_replace ( $ this -> _settings [ 'ext' ] , '' , $ filename ) ; foreach ( $ this -> _settings [ 'paths' ] as $ path ) { $ path = rtrim ( $ path , '/' ) . '/' ; if ( strpos ( $ filepath , $ path ) === 0 ) { $ filepath = str_replace ( $ path , '' , $ filepath ) ; } } $ config = [ 'asString' => true , ] ; $ text =  <<<JS
var hogan = require('hogan.js'),
    util = require('util');

try {
    var template = hogan.compile(%s, %s);
    util.print('\\nwindow.JST["%s"] = window.JST["%s"] = ' + template + ';');
    process.exit(0);
} catch (e) {
    console.error(e);
    process.exit(1);
}
JS ; $ contents = sprintf ( $ text , json_encode ( $ input ) , json_encode ( $ config ) , $ id , $ filepath ) ; file_put_contents ( $ file , $ contents ) ; }
Generates the javascript passed into node to precompile the
the mustache template.

@param string $file The tempfile to put the script in.
@param string $id The template id in window.JST
@param string input The mustache template content.
@return void
Generates the javascript passed into node to precompile the the mustache template .