How to make a snippet in an elevator - Scala

What I need to do is put one tag in the html page:

<lift:surround with="default" at="content"> <span class="lift:WorkingStatus.print"></span> </lift:surround> 

and have a snippet class in the corresponding snippet. * package:

 class WorkingStatus { def print():String={return "<table></table>";} def speak = <span>Hello World</span> def render = "* *" #> "Hello there in span" } 
Function

generates some html table in a row, which will be displayed in html, for example, in def print() .

So this is something pretty trivial, I just can't work. I need a Scala class that can be included wherever needed on html pages, for example - let say - using <jsp:include> , and this class should be able to connect to an external web service, get a list of some data and generate html, which can then be inserted in the right places ... is it difficult enough? :)

+4
source share
1 answer

You have the wrong signature for the print method. Snippets methods are NodeSeq => NodeSeq. So a more detailed option is
def print(xhtml:NodeSeq):NodeSeq={return <table></table>;} or you can use

 def print = "*" #> <table></table> 

if you need some kind of conversion or just:

 def print = <table></table> 
+1
source

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


All Articles