Why use ZPT-Sharp

Why learn and use another mechanism for creating dynamic HTML or XML documents? The ZPT syntax provides a number of advantages over other mechanisms currently in popular use.

Intuitive syntax

​​This is better shown than told:

<p>
  Hello
  <span tal:replace="name">Sam<span>
  how are you?
</p>

If you can read HTML/XHTML then you can read a ZPT source file.

Keeps the focus on the markup

ZPT is an attribute language, it extends HTML/XML with its own rendering attributes rather than using an entirely different syntax.

A ZPT source file maintains the structure of the intended output document which it is trying to create. Keeping the source closely related to the output helps designers and developers alike focus on the intended result, and not the details of how to get there.

Source files are valid HTML

ZPT syntax works within the structure of the underlying document (be that HTML or XML). Thus, a ZPT source file is still itself valid HTML/XML (plus some extra attributes).

Source files are viewable offline

With either ASP.NET web forms or Razor, you would not expect to meaningfully look at a source file in a browser, offline and away from the web application. If you tried, you would expect the display of the document to be broken by all manner of markup, logic and template directives.

ZPT source files do not suffer this disadvantage. You may view any valid source file in a web browser, offline from your application, and you will see a valid HTML document. Of course, without the application, the dynamic content will not be populated from the model. On the other hand, a CSS/HTML/JavaScript designer/developer should not need that content to do their work.

Third party HTML-editing tools are usable

Pages which include template markup are often difficult to use in third party web design applications & tools. Because the underlying structure of the HTML document is broken by the dynamic markup, the source file is uninteligible to the design application.

As above, ZPT source files do not suffer from this disadvantage, you may edit source files in a WYSIWYG editor if you wish, without hindrances.

Encourages separation of logic and markup

Because ZPT documents focus far more closely upon the markup, developers are less likely to insert blocks of .NET code into the markup files. Developers will find themselves encouraged to push such code into the model or the controller where it belongs and not into the view.