node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »



Textree is a NodeJS dynamic HTTP framework to build websites easily using a Jade-like syntax.

Feature summary

Jade-like syntax

The Jade syntax is a way to write HTML (or XML) in a human-friendly way. The Textree synax adds extra syntaxic features, such as dot-based attribute writing and inline tags:

    title Hello page
    h1 Hello world!
      h2 Sub title
      p This is some paragraph.
      p Another paragraphe with {span inline {b tags}}
      // This is an HTML comment

Asynchronous javascript control

Like with Jade, textree bring javascript controls, such as :if, :each, :var.

Better: they all work with promises, which means that :var content = asyncFunction() will be resolved with the promised value. Asynchonous calls are managed transparently!

For example, to show the GitHub issues of the official NodeJS repository (the requestHttpJson() function is provided by textree and returns a promise):

  h2 GitHub issues
  :each issue in requestHttpJson("")

            :attr.href = issue.user.html_url
              :attr.src = issue.user.avatar_url
              :process issue.user.login
            :attr.href = issue.html_url
            :process issue.title
          .style = whitespace:pre
          :process issue.body

Streaming magic

Textree is stream-oriented. It is compound of classes inheriting from Nodejs' stream.Transform.

:process is a smart instruction which pipes input from a newly instanciated stream transform object. For example:

  h2 Parsing "inline" Markdown
      # This is Markdown content
      ## Sub-title
      The Textree parser interprets this as a text block
      (because of the dot after ".ParseMarkdown"), which
      goes through ParseMarkdown where the Markdown syntax
      is transformed to HTML nodes as if they where written
      in Textree format in the first place.
  h2 Including a plain text file
      fs:path README
  h2 Including parsed nodes from a Markdown file
  h2 Including parsed nodes from Textree files
        fs:glob features/*.tt

Transform custom tags using in-flow templates

The :on instruction lets you capture a custom tag whenever it is met and replace it with a specific node structure:

:on ext
    :attr += ext.attributes
    :process ext.children
    .href =
    | This link will open in a new tab
    | and it has 

Templating is a core feature of Textree, meant to ease as much as possible the writing and maintenance of HTML/textree content.

We use templates for everything: building HTML documents, managing image frames with legend, extending markdown...

Serving HTTP content from a Git repository

All content is accessed from a Git repository branch. The environment variable TEXTREE_GIT_DIR must point to a valid and possibly bare Git repository (such as /var/lib/textree/repository).

Naturally, git-push is the favorite way to update the website. A post-update hook can send SIGHUP to tell the textree server that the branch has been updated.

This push-to-deploy strategy is a clean way to deploy atomic updates of the website: use any Git client to push your website content and once the transfer is done, the Textree server will start serving from the new tree. Absolutely no downtime!

Git is a powerful approach to managing content, since it archives all versions automatically, eases collaborations and provides interoperability through GitHub and the wide Git ecosystem.