-
|
Hello, I want to modify a webpage content, loaded as a Resource, to change some word So I'm trying to convert the HostBuffer returned by Resource to String so I can do: Is this possible? Is there any other better way? Thanks, Alberto. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
A import TextDecoder from "text/decoder";
let decoder = new TextDecoder;
let text = decoder.decode(resource);To use A lightweight solution is to use the XS API 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. |
Beta Was this translation helpful? Give feedback.
A
HostBuffercan generally be used like anArrayBuffer. You can convert it to a string using theTextDecoderAPI:To use
TextDecoderyou 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: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.