<commit_before><?php namespace Andriybazyuta\L4AssetEmblemjs\Filters;

use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;
use Codesleeve\AssetPipeline\Filters\FilterHelper;

class EmblemjsFilter extends FilterHelper implements FilterInterface 
{
    public function __construct($basePath = '/app/assets/javascripts/')
    {
        $this->basePath = $basePath;
    }

    public function filterLoad(AssetInterface $asset)
    {
        // do nothing when asset is loaded
    }
 
    public function filterDump(AssetInterface $asset)
    {
        $relativePath = ltrim($this->getRelativePath($this->basePath, $asset->getSourceRoot() . '/'), '/');
        $filename =  pathinfo($asset->getSourcePath(), PATHINFO_FILENAME);
        $filename = pathinfo($filename, PATHINFO_FILENAME);

        //$content = str_replace('"', '\\"', $asset->getContent());
        //$content = str_replace(PHP_EOL, "", $content);
        $content = $asset->getContent();
        //$jst = 'JST = (typeof JST === "undefined") ? JST = {} : JST;' . PHP_EOL;
        $jst = 'Ember.TEMPLATES["' . $filename . '"] = Emblem.compile(Handlebars, "';
        $jst .= $content;
        $jst .= '");'; //. PHP_EOL;

        $asset->setContent($jst);
    }
}<commit_msg>fix jst<commit_after><?php namespace Andriybazyuta\L4AssetEmblemjs\Filters;

use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;
use Codesleeve\AssetPipeline\Filters\FilterHelper;

class EmblemjsFilter extends FilterHelper implements FilterInterface 
{
    public function __construct($basePath = '/app/assets/javascripts/')
    {
        $this->basePath = $basePath;
    }

    public function filterLoad(AssetInterface $asset)
    {
        // do nothing when asset is loaded
    }
 
    public function filterDump(AssetInterface $asset)
    {
        $relativePath = ltrim($this->getRelativePath($this->basePath, $asset->getSourceRoot() . '/'), '/');
        $filename =  pathinfo($asset->getSourcePath(), PATHINFO_FILENAME);
        $filename = pathinfo($filename, PATHINFO_FILENAME);

        $content = str_replace('"', '\\"', $asset->getContent());
        $content = str_replace(PHP_EOL, "\\n", $content);
        
        //$jst = 'JST = (typeof JST === "undefined") ? JST = {} : JST;' . PHP_EOL;
        $jst = 'Ember.TEMPLATES["' . $filename . '"] = Emblem.compile(Handlebars, "';
        $jst .= $content;
        $jst .= '");'; . PHP_EOL;

        $asset->setContent($jst);
    }
}
{'fraction_non_alphanumeric': 0.16064908722109533, 'fraction_numerical': 0.0008113590263691683, 'mean_word_length': 3.130653266331658, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3313638', 'n_tokens_mistral': 792, 'n_tokens_neox': 771, 'n_words': 138}