Grails Asset-pipeline does not load angular partial templates
Asked Answered
A

3

6

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.

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

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

Ankara answered 28/2, 2014 at 5:16 Comment(4)
You can try to ask about it in github.com/bertramdev/asset-pipeline/issues?state=openYeung
have you found a solution to this problem? Currently I'm facing same problemHaile
@Riku I was using angular-ui-bootstrap for this implementation. I changed to use "angular-bootstrap" and it worked. There are 3 similar libraries - ui-bootstrap, angular-ui-bootstrap, angular-bootstrap. If you use bootstrap, ensure that you use "angular-bootstrap". Another (not-so-good) solution is to move the files into /webapp directory. I have my custom partials served from the /webapp directory.Ankara
@Ankara I have managed to include those from assets folder by just adding //= require folder_name. I have put folder_name folder under grails-app/assets/javascripts catalog. And now it works like a charm.Haile
G
2

Is template located in assets, if so remember the first level folders inside of assets are flattened so you may want to nest your templates one more level or adjust your path

Gemination answered 6/3, 2014 at 10:2 Comment(0)
F
2

I have tried putting the /partials directory under /web-app. It ends up like:

/web-app/partials/content.html

I don't need to mess about with asset-pipeline, it just works!

The versions I use are:

  • Grails: 2.4.2
  • compile ":asset-pipeline:1.8.11"

Hope this helps anyone who upgrades their Grails version as well.

Furman answered 4/8, 2014 at 16:23 Comment(0)
C
2

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.

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

views/partials/login.gsp

<div>Hello World!</div>

conf/UrlMappings.groovy

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

grails-app/assets/javascript/

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

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

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

Best regards, Björn

Consume answered 11/11, 2014 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.