Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Magnolia CMS为FreeMarker和JSP提供可立即使用的绘制器。您可以选择偏好的语言,甚至可以在相同的网站上混合使用,在一些模板里使用FreeMarker而另一些里用JSP。 

Freemarker

At Magnolia we prefer Freemarker for its flexibility, cleaner syntax and better error reporting, but also because it does not depend on the file system. Templates do not have to be extracted to the file system. This means you can store them in the repository and access like any other resources, apply version control if you wish, and add custom properties and metadata.

Example: Render the page title, or render the name if no title exists.

Code Block
<h3>${content.title!content.@name}</h3>

Here are some of the benefits that Freemarker offers:

在Magnolia里,我们更倾向于使用Freemarker,因其灵活性,较清晰的语法,更好的错误报告机制,也因为它不依赖于文件系统。模板不需要导出到文件系统,这意味着您可以将它们存储在内容库中,并像其他资源一样获得,随意添加版本控制,以及添加定制的属性和元数据。

样例:绘制页面标题,如果没有标题则绘制名字。

Code Block
<h3>${content.title!content.@name}</h3>

这是Freemarker提供的一些好处:

  • 它是一种通用的模板语言,不束缚于Java环境。
  • 提供基本的指令,如[if][else]和[list]
  • 有一大套built-ins
  • 可以调用任何Java对象和返回对象的公共方法。
  • 不需要在请求/回复环境中绘制。
  • 提供直接获取节点对象(beans)的方法。
  • 可直接迭代任何扩展一个Java列表的内容集合。
  • 严格的null值处理导致稳定的模板。
  • 需要的话允许使用JSP标签库。
  • It is a general templating language and not bound to any Java context.
  • Provides basic directives such as [if][else] and [list].
  • Has a large set of built-ins.
  • Can call public methods of any Java object and any returned object.
  • Does not need to be rendered in the request/response context.
  • Provides direct access to node objects (beans).
  • Can directly iterate any content collections that extend a Java list.
  • Strict null value handling leads to stable templates.
  • Allows the use of JSP taglibs if required.

JSP

JSP stands for JavaServer Pages. It is an extension of Java Servlet technology for combining Java server-side programs and HTML.

...