Skip to content
Discussion options

You must be logged in to vote

A HostBuffer can generally be used like an ArrayBuffer. You can convert it to a string using the TextDecoder API:

import TextDecoder from "text/decoder";

let decoder = new TextDecoder;
let text = decoder.decode(resource);

To use TextDecoder you will need to add its manifest, $MODDABLE/modules/data/text/decoder/manifest.json, to your project's manifest.json.

A lightweight solution is to use the XS API String.fromArrayBuffer:

let text = String.fromArrayBuffer(resource);

You mention "HandleBars style." It is possible to run Mustache.js in the Moddable SDK. See the Template node implementation of Node-RED MCU Edition for an example of that.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@albham
Comment options

Answer selected by albham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants