Skip to content

dslmeinte/littoral-templates

Repository files navigation

littoral-templates

A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript. It doesn't come with its own syntax, like frameworks like mustache, and handlebars do.

The repository's name is a play on "temporal literals" and "littoral", begin phonetically close to "literal". The latter word indicates the part of a body of water (lake, sea, or ocean) that's closest to shore, usually shallow, and possibly not always entirely submerged. The name tries to convey that implementing templates with this framework doesn't require you to "wade too far into the water".

Instead, templates look as follows:

import { asString, indentWith } from "littoral-templates"

const indent = indentWith("    ")

console.log(
    asString([
        `top-level`,
        [ `still top-level, but on a new line` ],
        indent(1)([
            `this is indented (1 level)`,
            indent(2)([
                `this is much more indented (3 levels)`
            ])
        ])
    ])
)

(The contents of the code above can be found in src/test/test-in-README.ts as well.) This code produces the following text on the JavaScript console:

top-level
still top-level, but on a new line
    this is indented (1 level)
            this is even more indented (3 levels)

TODOs

  • Publish to NPM (including proper cleaning and ignoring).
  • Proper test set up, e.g. using mocha and chai.
  • Skip undefined | nulls.
  • Does an alternative to npm-run-all exist (that's better)?

About

A small JavaScript/TypeScript framework to do templating comfortably using JS/TS' template literal syntax.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published