Closed ernani closed 7 years ago
Hi @ernani, I don't understand what you refer about integrating web jars, play-bootstrap, and about injecting the webjars into the view. Could you elaborate a test project or write here the code you are using and the error you get?
Hi Adrian, thanks for replying quickly!
The thing is, by looking at your sample here: https://github.com/adrianhurt/play-bootstrap/blob/master/play26-bootstrap4/sample/app/views/main.scala.html
It seems it links the libraries from webjars already by referencing /lib in routes.Assets.at
But I think I got it confused with this lib:
https://github.com/webjars/webjars-play which leads to a parent project on top of my own which then uses dependency injection to inject the utility class into twirl templates.
This file:
Contains on the top of it the following call: @this(webJarUtil: org.webjars.play.WebJarsUtil)
https://github.com/webjars/webjars-play/blob/master/test-project/app/views/index.scala.html
And my views have child views, which requires some parameters such as string for title as well as in my
child template, another references to that webJarUtil component. The thing is that my main template calls @head_template.scala.html and it doesn't seem to find it.Also there is another test project of webjars-play that doesn't require the parent project as it uses a compiled version of it, and that also has been failing to work.
I guess I've mixed up the libraries and hence this is why it fails. I will try to keep yours and give up that one, that should work fine.
Again, thanks a lot and have a great weekend!
Ok, I see. It's really a question about Play and WebJars, and my knowledge on this is limited 😉
As I understand seeing that code and docs here:
The use of the helper webjars-play
it's optional and helps to reference Webjars assets. I've never used the constructor @this()
for templates, so I'm not sure how they have to be called. So I'll try this, but as I said, I've never worked with this constructor so I don't really know.
main.scala.html
@this(webJarUtil: org.webjars.play.WebJarsUtil)
@(param1: String, ...)
…
@head(title = "my title")
...
head_template.scala.html
@this(webJarUtil: org.webjars.play.WebJarsUtil)
@(title: String)
…
<title>@title</title>
...
I am pretty sure this has nothing to do with play-bootstrap. We changed all our templates to make use of DI via @this(..)
and everything works great.
I was able to load both, part of it is because it requires an injected view instead of just a regular link to it in the Controller classes. It all works like a charm now, I will now close the issue.
Also thanks for providing such awesome component, it saves a lot of time.
Best Regards!
I wanted to integrate webjars, play-bootstrap in my play 2.6 project.
The problem is that the webjars needs to be injected into the view, then I can't pass or load params in these templates anymore
list.scala.html (injected webjars-play) -> loads -> main.scala.html
In main.scala I have some other templates injected such as @main_header.scala.html which contains the webjars scripts, but it won't compile.
Maybe I am missing a point here.
If you could please elucidate me. I am new to this. Thanks