Prevent FlashFramework Template Template Launch

I have created several utilities that help me generate HTML, and I refer to them in my views as @div( "class" -> "well" ){ Hello Well. } @div( "class" -> "well" ){ Hello Well. } . So far, these classes have been subclassed by NodeSeq because they are not escaped . But I need to get rid of NodeSeq at the top of my class hierarchy because Scala xml has flaws and makes my code hacked and because I can switch to Traits then.

So, I tried to figure out how to prevent the game from the screens of my Tag objects. But, unfortunately, the only valid solution I found was to override the template compiler and specify its compiler in the settings of Build.scala .

But I hope the easier way has gone astray?

+4
source share
2 answers

Starting with version 2.2.0-M1 , a new approach has appeared in the documents, which explains how to add custom formats to the template engine. This allows me to easily integrate my utilities.

Custom Template Format: Java , Scala

+3
source

If your html helpers return "Html" rather than String, you don’t need to wrap them using the @Html tag in the view.

eg,

 import play.api.templates.Html def a(src: String, value: String) : Html = Html(s"<a href='$src'>$value</a>") 

Will be called in the view as shown below, without the need for wrapping in @Html

 @a("www.example.com", "Example") 
+3
source

Source: https://habr.com/ru/post/1499143/


All Articles