Projects‎ > ‎XForms‎ > ‎

Making XForms DRY with Haml or Jade

NOTE: This page describes an Orbeon Forms project, not a feature which is currently part of Orbeon Forms.


Rationale

  • Make markup beautiful, DRY, and well-indented. (Which are some of the principles of Haml and inline with using CoffeeScript for actions.)

  • Avoid namespace declarations that are always the same can be automatically inferred with simple rules, e.g. see the rules here: XForms Without Namespaces.

Example

This Haml version of the XForms Hello example.

%html
    %head
        %title XForms Hello
        %model
            %instance
                %first-name
    %body
        %p
            %i
                This example is described in details in the
                %a(href="/doc/intro-tutorial") Orbeon Forms Tutorial
            %input(ref="/first-name" incremental="true")
                %label Please enter your first name
        %group(ref=".[normalize-space(/first-name) != '']")
            %output(value="concat('Hello, ', /first-name, '!')" )

Or the same in Jade:

html
    head
        title XForms Hello
        model
            instance
                first-name
    body
        p
            i
                | This example is described in details in the
                a(href="/doc/intro-tutorial") Orbeon Forms Tutorial
            input(ref="/first-name" incremental="true")
                label Please enter your first name
        group(ref=".[normalize-space(/first-name) != '']")
            output(value="concat('Hello, ', /first-name, '!')" )

Both Haml and Jade are supported by Scalate.
Comments