AF-BedSheetMoustacheUser Guide

Overview

afBedSheetMoustache is a Fantom library that integrates Mustache templates with the afBedSheet web framework.

It provides a cache for your compiled Mustache templates and throws MoustacheErrs to show details of any compilation failures.

Example:

Moustache Compilation Err:
  file:/C:/Projects/Fantom/BedSheetMoustache/test/app/compilationErr.moustache : Line 11
    - Unbalanced "{" in tag "{ alienHeadSvg }  <span class="brand">{{ title"

     6:         {{{ bedSheetCss }}}
     7:     </style>
     8: </head>
     9: <body>
    10:     <header>
==> 11:         {{{ alienHeadSvg }
    12:         <span class="brand">{{ title }}</span>
    13:     </header>
    14:
    15:     <main>
    16:         {{{ content }}}

Sections are added to the standard afBedSheet Err page to show the same.

Quick Start

using afIoc::Inject
using afBedSheet::Text
using afBedSheetMoustache::MoustacheTemplates

const class RouteHandler {

  @Inject
  private const MoustacheTemplates templates

  new make(|This|in) { in(this) }

  Text renderPage() {
    html := templates.renderFromFile(`res/index.moustache`.toFile)
    return Text.fromHtml(html)
  }
}

Usage

To use afBedSheetMoustache just add it as dependency in your project's build.fan. Example:

depends = ["sys 1.0", "afIoc 1.4+", "afBedSheet 1.0+", "afBedSheetMoustache 1.0+", ... ]

...and that's it!

Because afBedSheetMoustache defines pod meta-data for afIoc, no more configuration or setup is required.

Release Notes

v1.0.2

v1.0.0

v0.0.2

  • New: Preview release.