diff --git a/docs/500.html b/docs/500.html index 33e76bb..6e726b6 100644 --- a/docs/500.html +++ b/docs/500.html @@ -21,7 +21,7 @@ - + @@ -54,7 +54,8 @@

Oops...

Something went wrong. Please try again later.

-
examples is not defined
+
Build failed with 1 error:
+../temple/dist/Exception.js:8:15: ERROR: [plugin: temple-document-server-plugin] Mismatched closing tag ide-code
diff --git a/docs/build/client/055f1a2f37d39d4fe92a.html b/docs/build/client/055f1a2f37d39d4fe92a.html index 33e76bb..6e726b6 100644 --- a/docs/build/client/055f1a2f37d39d4fe92a.html +++ b/docs/build/client/055f1a2f37d39d4fe92a.html @@ -21,7 +21,7 @@ - + @@ -54,7 +54,8 @@

Oops...

Something went wrong. Please try again later.

-
examples is not defined
+
Build failed with 1 error:
+../temple/dist/Exception.js:8:15: ERROR: [plugin: temple-document-server-plugin] Mismatched closing tag ide-code
diff --git a/docs/build/client/13781afd4fbd704a9789.html b/docs/build/client/13781afd4fbd704a9789.html index 3416a5b..c216da7 100644 --- a/docs/build/client/13781afd4fbd704a9789.html +++ b/docs/build/client/13781afd4fbd704a9789.html @@ -83,6 +83,91 @@
Contributing

Developer Tools

+ + + Temple provides a separate package for a better development + experience when working with server frameworks that utilize + the native http module. Start by installing adding + '@ossph/temple-dev' + to your project. + + + + npm install --save-dev @ossph/temple-dev + + + + Next, import the dev() + function from the package and use it in your existing + 'src/index.ts' + file to create a development server as shown in the example below. + + + + import http from 'http'; + import temple from '@ossph/temple/compiler'; + import { dev } from '@ossph/temple-dev'; + + //create temple compiler + const compiler = temple({ cwd: __dirname }); + //1. create dev tools + const { router, refresh } = dev({ cwd: __dirname }); + + //create http server + const server = http.createServer(async (req, res) => { + //2. Add dev router + if (router(req, res)) return; + //if home page + if (req.url === '/') { + //3. sync builder with refresh server + refresh.sync(compiler.fromSource('./page.dtml')); + //compile the document + const html = await compiler.render('./page.dtml'); + //... send response ... + } + //... other routes ... + }); + //listen on port 3000 + server.listen(3000); + + + + Lastly, update the document file + 'src/page.dtml' + to include the development script + <script src="/dev.js"></script> + as shown below. + + + + <script> + //... + </script> + <html> + <head> + <!-- ... --> + <!-- 4. include dev script --> + <script src="/dev.js"></script> + </head> + <body> + <!-- ... --> + </body> + </html> + + + + Run the following command in terminal. + + + + npx ts-node src/index.ts + + + + Whenever 'src/page.dtml' + is updated, the development server will automatically refresh + the page. Components will also be updated in real-time. +