Sunday, March 23, 2014

Scala Play Framework Template Imports

The template compiler is pretty sweet. Using a template like a function is awesomely simple.  If you have a bit of html code that makes up a reused block on more than one page you just factor it out to it's own ___.scala.html. Then reference it with the "magical" @ character.

However, the error messages that the template engine provides are less-than-detailed. I had created a subdirectory named: app/views/tags. When I tried to use one of the template functions out of that directory I got the error: not found: value gallery

So let's take a look at the important parts.

I have templates:

  • app/views/main.scala.html
  • app/views/tags/gallery.scala.html
With this as the important parts of main.scala.html

@(artist: models.ArtistModel,
      tags: List[String])(implicit artistModel: Option[models.ArtistModel]) @import tags._
.....
...
@gallery()....
Hmmmm, "not found: value gallery"? Why can't it find gallery? I imported it. It's formed correctly. Well, this is painfully obvious now, but it took a few minutes for me to reconcile that the "tags: List[String]" is clashing with the "@import tags._" 

More on the Play Framework Templates

4 comments:

thanida said...

Thanks for giving the information it is useful for me.
ufabet

คนสวย2019 said...

ปรับรูปหน้าเรียว
ฉีดหน้าเรียว ลดริ้วรอย เป็น



ต้องการ



หน้าเรียวทำเป็น



ยังไง



ผู้คนจำนวนไม่ใช้น้อย













อาจจะ







กำเนิด



ปัญหา





นี้
รวมทั้ง







การฉีดลดหน้าเรียวด้วยโบท็อกก็เป็นแนวทางการ











รักษาที่ทำเป็น



ง่าย โดยไม่ต้องผ่าตัด
สารารถยนต์



ช่วยลดลางเลือน



ริ้วรอยรวมทั้ง







ร่องลึกได้ภายในช่วงระยะเวลา







เร็ว







ได้ผล



การดูแลและรักษา





ที่น่าพอใจ



ละสร้างความเชื่อมั่น








โบท็อก หน้าเรียว
ฉีดโบท็อก ที่ไหนดี

supersonic100g9 said...

รถเช่าดอนเมือง ถ้าคุณเดินทางด้วยเรือบินมาลงที่ท่าอากาศยานดอนเมือง รวมทั้งกำลังมองหา รถเช่าที่ท่าอากาศยานดอนเมือง ราคาไม่แพง BANANA rent-a-car พวกเราเป็น บริษัทยานยนต์เช่าในเขตดอนเมือง ที่พร้อมให้บริการไม่ว่าคุณจะบินไปดอนเมือง กรุงเทวดาเพื่อพักระยะสั้นหรืออยู่ยาว ก็เครียดลดลงจากการเดินทางได้ด้วยการเช่ารถยนต์ ด้วยโครงข่ายบริษัทยานยนต์เช่าที่มีให้เลือกมากไม่น้อยเลยทีเดียว Banana-rent-a-car ช่วยทำให้คุณค้นหาข้อแนะนำที่เหมาะสมที่สุดได้ เพียงแต่บอกวันเดินทาง พวกเราก็จะแสดงรถยนต์ที่มีให้ท่านมอง รวมทั้งที่สำคัญกว่านั้น พวกเราจะแสดงเพราะบริษัทใดตีราคาให้เยี่ยมที่สุด เช่ารถยนต์ง่าย ได้รถยนต์ไว โดยไม่ต้องมีบัตรเครดิตก็เช่ารถยนต์ได้รวมทั้งมีบริการส่งรถยนต์ถึงที่บริษัทรถเช่า
รถเช่าสุวรรณภูมิ
รถเช่าระหว่างซ่อม
รถเช่าไม่ใช้บัตรเครดิต
เช่ารถเก๋ง
รถรับส่งสนามบิน

Unknown said...

สมัคร จีคลับ
สมัคร บาคาร่า
สมัคร gclub