\r\nJavascript and HTML packed into one wrapper. Handle server code directly in your HTML, all behind the scenes.\r\n\r\n## Installation\r\n\r\nEccentric is a npm module for NodeJS\r\nYou need to have Node installed in order to install this package.\r\nYou can install Eccentric by running this code:\r\nbash\r\n$ npm i eccentric\r\n
\r\n\r\n## Usage\r\n\r\nindex.js
:\r\njs\r\nconst express = require(\"express\");\r\nconst app = express();\r\nconst eccentric = require(\"eccentric\");\r\n\r\napp.use(eccentric)\r\n\r\napp.get(\"/\", (req, res) => {\r\n res.build(\"web.js\", {\"outside\":\"Eccentric also supports outside variables!\"})\r\n});\r\n\r\napp.listen(3000);\r\n
\r\n\r\nweb.js
:\r\njs\r\n// My really cool app\r\n\r\nlet title = \"Hello world! 1+1 is \";\r\n\r\n<html>\r\n <head>\r\n <title =>title + String(1+1)</title>\r\n <style>* {-family: sans-serif;}</style>\r\n </head>\r\n <body>\r\n <h1 =>outside</h1>\r\n <p =>\"The current date and time is \" + new Date()</p>\r\n <small>Eccentric also supports normal HTML :)</small>\r\n </body>\r\n</html>\r\n
\r\n\r\nYou can view a live example of this demo here.\r\n\r\n## Syntax\r\n\r\nDo:\r\nhtml\r\n<style>* {color: blue;}</style>\r\n
\r\n\r\nDon't:\r\n\r\nhtml\r\n<style>\r\n* {\r\n color: black:\r\n}\r\n</style>\r\n
\r\n\r\nEccentric parses HTML elements in their lines. This is to allow Javascript to be written inbetween elements. As an alternative, you can use links/sources to CSS and script tags.\r\n\r\n#### Example:\r\n\r\nhtml\r\n<script src=\"https://example.com/script.js\"></script>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"https://example.com/stylesheet.css\" />\r\n
\r\n\r\n#### Rendering\r\n\r\nIn order to render, Eccentric uses the function response.build
.\r\nThis compiles the Eccentric code, and sends the compiled HTML to the browser to be displayed.\r\n\r\nThere are three inputs for the build function:\r\nres.build(FilePath, Variables, isFile)
\r\nThe filepath is the location of the file that is being compiled.\r\nVariables is a JSON that stores variables/strings/objects that you would like to use in rendering.\r\nThe formatting of a variable consists of:\r\njson\r\n{\"variableName\":\"variableValue\"}\r\n
\r\nNote that variableValue
can be any type of Javascript value.\r\n\r\nisFile is a true or false statement that is optional. If it is left undefined, its default is true. If it is set to false, it will read FilePath
as a string to be parsed.
eccentric
1.0.7 • Public • PublishedPackage Sidebar
Install
npm i eccentric
Weekly Downloads
5
Version
1.0.7
License
MIT
Unpacked Size
5.43 kB
Total Files
3