moappi / json2html

Json2html is a lightning fast client side javascript HTML templating library with wrappers for both jQuery and Node.js.

Home Page:https://www.json2html.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: ENOENT: no such file or directory

debugger22m opened this issue · comments

Hi,

I have been having this issue and I don't know how to fix it. I even tried the example from the docs and its still not working.

let html = $.json2html([{'s':'json2html'},{'s':'is'},{'s':'awesome'},{'<>':'li','html':'${s}'});

[Error: ENOENT: no such file or directory, open '<li>json2html</li><li>is</li><li>awesome</li>'] {
  errno: -2,
  code: 'ESTREAM',
  syscall: 'open',
  path: '<li>json2html</li><li>is</li><li>awesome</li>',
  command: 'API'
}

Thanks!

Firstly are you using json2html on the browser or node.js?

Secondly if you want to use the jquery plugin best to attach it to an html element

$("ul").json2html([{'s':'json2html'},{'s':'is'},{'s':'awesome'},{'<>':'li','html':'${s}'});

Thirdly it looks like you are using the html output as a file name instead of html.

Hi,

Thank you for replying. I'm using json2html in NodeJS. I have been trying out some variations, this is what my code looks like.

let transform = {'<>':'li','html': [ {'<>':'span','html':'Port: ${port}'}]};
let payload = JSON.stringify(res.rows);
let html =   json2html.transform(payload, transform);

[Error: ENOENT: no such file or directory, open '<li><span>Port: 3</span></li>']

Thanks again,

For node.js use json2html.transform .. it will return an html string (not a file)

let transform = {'<>':'li','html': [ {'<>':'span','html':'Port: ${port}'}]};
let html =   json2html.transform(res.rows, transform);
console.log("html",html)

ok, thank you!