Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A little compiler compiling DOM fragments in XML to DOM-building JavaScript functions

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
project
src/main/scala/xsbtDomc
.gitignore
LICENSE
README
build.sbt

README

A little compiler compiling DOM fragments in XML to DOM-building JavaScript functions

To build this code, get and install SBT from 
    https://github.com/sbt/sbt

Get and install these library/libraries before building:
    https://github.com/ritschwumm/xsbt-util
    https://github.com/ritschwumm/xsbt-webapp
    
Use these commands to build:
    git clone git@github.com:ritschwumm/xsbt-domc.git
    cd xsbt-domc
    sbt publish-local

What it does

    If you compile an XML snippet like this
    
        <div xid="Message">
            <span xid="text"/>
            <a xid="remove">x</a>
        </div>
    
    you get a JS function like this
    
        function Message() {
            ... // create a DOM structure
            return {
                // the toplevel tag is always accessible under this name
                "$":        ... // the toplevel div
                // if a tag has an xid, it is accessible under that name
                "Message":  ... // the toplevel div by its xid
                "text":     ... // the text-span by its xid
                "remove":   ... // the remove-link by its xid
            }; 
        }

    There is no support for conditionals, looping or any logic.
    These need to be done in JS code outside the template mechanism.
    
Sbt Plugin (package domc-sbt)
    
    Add the plugin to your project in project/plugins.sbt:
    
        addSbtPlugin("de.djini" % "xsbt-domc" % <version>)
        
    Put dom files (named *.dom) sources into
    
        src/main/webapp
        
    Include domc in the webapp pipeline:
    
        webappPipeline      += domcProcessor
Something went wrong with that request. Please try again.