English 中文(简体)
• 如何在吊销中装上刀子——
原标题:How to make a snippet in Lift - Scala
  • 时间:2011-11-10 16:42:16
  •  标签:
  • scala
  • lift

我需要做的是把一个标签放入html网页:

<lift:surround with="default" at="content"> 

<span class="lift:WorkingStatus.print"></span> 

</lift:surround> 

a. 在适当的狙击手表* 中有一刀子。

class WorkingStatus {

  def print():String={return "<table></table>";}

  def speak = <span>Hello World</span>

  def render = "* *" #> "Hello there in span"
} 

功能将产生约html的插图,如<编码>def 印刷(<>/代码>)。

因此,这是我无法以任何方式工作的一个非常棘手的问题。 我需要一个可以在必要时纳入html网页的Schala级,例如:<jsp:include>;这一类别应当能够连接外部网络服务,获得一些数据清单,并生成html,然后在所希望的地点插入......这足够复杂?

问题回答

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

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

如果您需要某种转变,或者说:

def print = <table></table>




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...

热门标签