Marko: Marko makes it easy to represent your UI using a syntax that is like HTML. It is a friendly and super fast UI library that makes building web apps bearable fun. It is so much like HTML, that you can use it as a replacement for a templating language like handlebars, mustache, or pug.
However, Marko is much more than a templating language. It’s a language that allows you to declaratively build an application by describing how the application view changes over time and in response to user actions. In the browser, when the data representing your UI changes, Marko will automatically and efficiently update the DOM to reflect the changes.
Installation: If you’re starting from scratch, you can use Marko’s cli commands to quickly create a starter app:
The Marko compiler runs on Node.js and can be installed using npm:
npm init -y // The -y installs the default package.json
We need to install the following required libraries:
npm install express --save // install express module npm install marko --save // install marko module or using yarn: yarn add marko
Example: Filename: template.marko
Equivalent code of Template.marko:
Run index.js file using the following code in cmd:
Output (In Console):
Server started at port 2020…
Routing done all fine…
Note: After Running the server in console, it automatically creates a file template.marko.js, which has a reference to all the template files.