Asseticをサポートするために(Symfony2)SmartyBundle拡張機能を書いています。
スタイルシート機能をサポートするために、次のブロックプラグインを登録しましたstylesheets
:
{stylesheets
assets='@SmartyBundle/Resources/public/css/*'
debug=true}
<a href="{$asset_url}">{$asset_url}</a>
{/stylesheets}
このプラグインは適切に呼び出され、Symfony/asseticキャッシュが作成されるとすべてが期待どおりに機能します。
この問題は、Symfonyキャッシュが空で、Asseticがすべてのテンプレートファイルリソースをロードし、スタイルシートタグで見つかったトークンを使用してPHP配列を取得するようにテンプレートエンジンに要求した場合に発生します。配列を取得するために呼び出されるクラスはですSmartyFormulaLoader
。
<?php
class SmartyFormulaLoader implements \Assetic\Factory\Loader\FormulaLoaderInterface
{
public function load(ResourceInterface $resource)
{
// raw template content
$content = $resource->getContent();
// a FileLoaderImportCircularReferenceException is throw here
$smartyParsed = $this->smarty->fetch('string: '.$content);
// build an array with tokens extracted from the block function
$formulae = $this->extractStylesheetsTokens($smartyParsed);
return $formulae;
}
$smarty->fetch()
メソッドでが呼び出されると、load()
例外がスローされますSymfony\Component\Config\Exception\FileLoaderImportCircularReferenceException: Circular reference detected in "." ("." > ".")
。
これは、Smartyテンプレートが解析/コンパイルされ、stylesheets
プラグインが再度呼び出されたことが原因です。
そこで、Smartyが(スタイルシートプラグインを呼び出さずに)ブロック関数トークンを抽出するテンプレートパーサーを提供して、Asseticにフィードできるかどうかを尋ねています。または、これを解決するために私が見逃している可能性のある他の解決策。
ありがとう。