From 4bf3a68f43e4fcea34fe0a16cb3e1eecb97d332a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 10 Sep 2018 14:40:33 +0200 Subject: Fixed assets rendering --- src/Renderer/Twig/Extensions/Assets.php | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Renderer/Twig/Extensions/Assets.php (limited to 'src/Renderer/Twig/Extensions/Assets.php') diff --git a/src/Renderer/Twig/Extensions/Assets.php b/src/Renderer/Twig/Extensions/Assets.php new file mode 100644 index 00000000..2cdfb0fd --- /dev/null +++ b/src/Renderer/Twig/Extensions/Assets.php @@ -0,0 +1,42 @@ +urlGenerator = $urlGenerator; + } + + /** + * @return TwigFunction[] + */ + public function getFunctions() + { + return [ + new TwigFunction('asset', [$this, 'getAsset']), + ]; + } + + /** + * @param string $path + * @return UrlGenerator|string + */ + public function getAsset($path) + { + $path = ltrim($path, '/'); + + return $this->urlGenerator->to('/' . $path); + } +} -- cgit v1.2.3-54-g00ecf