English 中文(简体)
在模板中处理有条件内容的首选取道是什么?
原标题:What is the preferred Lift way to handle conditional content in a template?
  • 时间:2011-08-28 16:38:31
  •  标签:
  • scala
  • lift

在模板中处理有条件内容的首选取道是什么?

作为一个具体例子,请允许我想象一下“向我的福武特人”型纽顿的共同构造。 如果你们不喜欢的话,就有一个纽子去点添加。 如果你已经赞成,就会有一个州去除。 与此类似:

<div class="lift:MySnippet">

  <!-- other stuff -->

  <div class="favorite">
    <form id="doFavorite" class="lift:MySnippet.favorite?form=post">
      <input type="submit" value="Add to Favorites" />
    </form>
    <form id="doUnfavorite" class="lift:MySnippet.unfavorite?form=post">
      <input type="submit" value="Remove from favorites" />
    </form>
  </div>

  <!-- other stuff -->

</div>

我看不出尼伯(通过具有约束力的或CSS的变压器)的明显方式,即有条件地根据适当的“艰难”状态保留一种形式。

从Java/SpringMVC/JSP的背景情况来看,这将通过简单的<代码><c:choose>说明加以解决,但随着我花在试图表明这一点上的时间,我只能假定我正在经历这种彻底的倒退......

Thanks in advance, Lift gurus!

最佳回答

我没有声称是电梯,但这里有两个选择,对我来说似乎是合理的:

有一个刀子,一个“<条码> ——DoOr UndoFavorite,在这个版面,你将检查用户的有利状态,并填写一个或另一个(if(favorited){...} 否则

<>>>

保存您的刀切,并在每张刀子的代号内,作为<代码>Nil的标签,如果该编码不能生效,则作为您的约束力。

问题回答




相关问题
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 ...

热门标签