We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Adding an entire CSS/JS directory using volt

Is it possible to add an entire directory using volt?

{# Rather than doing this: #}
{{ javascript_include('js/file1.js') }}
{{ javascript_include('js/file2.js') }}
{{ javascript_include('js/nested/file3.js') }}

{# Could we do something like this to recursively include all files of type '.js' #}
{{ javascript_include('js/**/*.js') }}

Is this possible, in one way or another?

edited Aug '14

I don't believe that functionality is available with stock Volt. You could build your own volt function to allow yourself to do that.

https://docs.phalcon.io/en/latest/reference/volt.html#id1 with a mixture of scandir() and/or https://php.net/manual/en/class.recursivedirectoryiterator.php.

If you do go ahead with it, I'd recommend using caching to store the file paths, to save the directory from having to be re-scanned every request.

Ok, I was just curious. It might be something to consider implementing in the future; something like .NET MVC Bundles. In the meantime I'm just using grunt (w/ concat, cssmin, uglify, watch plugins) to do the equivalent.