1.0.2 • Published 6 years ago

htmlwithjs v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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
1.0.2

6 years ago

1.0.1

6 years ago