Grails的资产管道不加载角部分的模板管道、加载、模板、资产

2023-09-13 03:02:47 作者:互撸娃

林采用了棱角分明的UI,引导使用Grails 2.3.x版本资产管道:1.6.1插件。其中一个组件 - alert.js试图加载/template/alert/alert.html但这解析为404

Im using angular-ui-bootstrap with Grails 2.3.x asset-pipeline:1.6.1 plugin. One of the components - alert.js is attempting to load /template/alert/alert.html but this resolves to 404.

我试过,包括grails.assets.includes = [*的 / 的的.html],并没有帮助。

I tried including grails.assets.includes=[*/.html], did not help.

任何解决方法吗?反正让资产管道包括部分模板?

Any workaround for this? Anyway to let asset-pipeline include partial templates?

推荐答案

感谢您的有关AngularJS和Grails ,从此开始了我对这个话题伟大的博客。

thanks for your great blog about AngularJS and Grails, which jumpstarted me on this topic.

关于谐音,我假定资产目录不是把它们正确的地方,因为他们得到的级联,并在生产方式缩小的。

Regarding partials, I assume the assets directory is not the right place to put them, because they get concatenated and minified in production mode.

相反,我使用GSP模板作为AngularJS谐音。例如,我有

Instead, I use GSP templates as AngularJS partials. For example, I have

的意见/谐音/ login.gsp

<div>Hello World!</div>

的conf / UrlMappings.groovy

static mappings = {
  ...
  '/partials/login'(view:'/partials/_login')
}

的grails-app /资产/ JavaScript的/

...
templateUrl: 'partials/login',
...

优点:你甚至可以使用脚本使和谐音标记库

Advantage: You may even use script lets and taglibs in the partials.

这是另一种使用GSP直接将詹姆斯Kleeh在这个线程方法。

An alternative to using GSP directly would be James Kleeh's approach in this thread.

最好的问候,比约恩

Best regards, Björn