Skip to content
No description, website, or topics provided.
TypeScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
docs
node_modules
.gitignore
LICENSE
README.md
hwjs.js
hwjs.js.map
hwjs.ts
package-lock.json
package.json
tsconfig.json

README.md

hwjs

Embed server-side javascript into html.

Docs here

Express demo server here

Install: npm i htmlwithjs

Every execution a new node vm is created with the vm module

By default embedded scripts do not have access to things like require, but you can pass them down to the sandbox.

In order to have your code executed you need to have the <!--hwjs--> header at the begining of your file.

Server side scripts start with <script server> and simply end with </script>. Do not use <script server="true"> or anything else becouse it will be executed on the client-side.

example code:

<!--hwjs-->
<!DOCTYPE html>
<html>
<body>
    Hello <script server>write("World");</script>
</body>
</html>

gets translated to

<!--hwjs-->
<!DOCTYPE html>
<html>
<body>
    Hello World
</body>
</html>

Planned features

  • Caching output
  • The ability to execute streams
You can’t perform that action at this time.