我正在研究一个AngularJS / Symfony项目,我无法弄清楚如何在我的js中正确定义树枝模板的路径。
路径: - 原始JS - 模板 - 具有资产的JS路径
...
+-src/
| +-MyCompany/
| +-MyBundle/
| +-Resources/
| +-public/
| +-js/
| +-directive/
| +-my_file.js
| +-view/
| +-template/
| my_template.html.twig
+-web/
| bundles/
| +-MyBundle/
| +-js/
| +-my_fil.js
...
我的js代码:
return {
templateUrl: '?'
}
那么,有没有办法将捆绑包中的路径包含到资产文件中? (我尝试了@ bundle / notation,但没有用)。 或者,当我在我的html中包含js时,要使用捆绑包的js而不是资产中的一个?
由于
答案 0 :(得分:1)
That would be
{% javascripts filter='?uglifyjs2'
'@AppBundle/Resources/assets/js/your-file.js'
'@AppBundle/Resources/assets/js/your-second-file.js'
'@AppBundle/Resources/assets/js/admin-*.js'
%}
<script type="text/javascript" src="{{ asset(asset_url) }}"></script>
{% endjavascripts %}
The filter allows you to apply, for instance, UglifyJS
in this example. The path points to src/AppBundle/Resouces/assets/js/
and will combine the two files. It's even possible to use wildcards.