iotdb-format

Simple String Formatting and Templating

Usage no npm install needed!

<script type="module">
  import iotdbFormat from 'https://cdn.skypack.dev/iotdb-format';
</script>

README

iotdb-format

Yet another bloody module: simple, somewhat powerful, string formatting

This isn't really finished: it needs a proper grammar, maybe using JISON.

Format Strings

const iotdb_format = require('iotdb-format')
const d = {
    message: "Hello, World"
}

iotdb_format.format("{{ message }}") // "Hello World"
iotdb_format.format("{{ message|upper }}") // "HELLO WORLD"
iotdb_format.format("{{ xmessage|:Something Else }}") // "Something Else"
iotdb_format.format("{{ xmessage|:Something Else|lower }}") // "something else"

Format Objects

const iotdb_format = require('iotdb-format')
const d = {
    msg: {
        hello: "Hello",
        world: "World",
    }
}

iotdb_format.format({
    list: [ "{{ msg/hello }}", "{{ msg/comma|:, }}", "{{ msg/world|upper }}", 3.14 ]
}, d)

// result: { list: [ 'Hello', ',', 'WORLD', 3.14 ] }