0
votes

I want to create and use a tag, to reuse my html-component in playframework 2.

My tag: /views/mytags/words_tag.scala.html

Code:

@(words: List[String] = List())

<ul id="words">
    @for(word <- words) {
        <li> <a href="/article/@word" onclick="#">@word</a></li>
    }
</ul>

Try to use in my index.scala.html:

@import views.mytags._
@words_tag(words)

As result I have a compilation error on the page:

illegal start of simple expression *app/views/index.scala.html at line 9.*

@import views.mytags._

Why?

Updated: LOG is:

sbt.PlayExceptions$CompilationException: Compilation error[illegal start of simple expression] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na] at scala.Option.map(Option.scala:133) ~[scala-library.jar:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:349) ~[na:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:346) ~[na:na] at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]

3

3 Answers

0
votes

your file named words_tag.scala.html, not words_tags. The difference in last s

0
votes

Try importing views.html.mytags._

0
votes

It seems I know the reason. Will check it latter.

I need to use import mytags._ without "views".

It is not obvious but that what the documentation says about this.