Node.js Project to Convert HAML Template to HTML Markup Using htmlcompile Command Line Library Full Tutorial For Beginners
Welcome folks today in this post we will be converting haml to html
using htmlcompile
library. All the full source code of the application will be given below.
Get Started
In order to get started you need to install htmlcompile
library globally inside your system. You can issue the following npm
command
npm i -g htmlcompile
Here we are using the global flag -g
to install globally. Now we can use this library anywhere inside the system.
Converting HAML Template to HTML
Now you can issue the following command to convert haml
to html
For this we need to create a input directory src
and there just create a index.haml
file and copy paste the following code
index.haml
!!! 5
%html
%head
%title HAML to HTML Free Online Converter
%meta(author="HAML Online Converter 2012")
%body
#content
.entry-title Welcome To HAML to HTML Converter Online
.entry-content
Enter your HAML code here...
HAML to HTML code will update automatically or on ENTER button.
#footer
%ul#links
%li
%a(href="/") Homepage
%li
%a(href="/what-is-haml/") What is HAML?
%li
%a(href="/how-to-use-haml/") HAML usage examples
© HAML Online Converter 2012. All rights reserved.
Now you can convert this code to html
by the below command
htmlcompile inputdirectory outputdirectory
Here inputdirectory is the directory where input files are present
And outputdirectory is the directory where output files are present
htmlcompile src dist
So it will convert all the files which are present in src
directory to html
And it will create output dist
directory and it will create index.html
file inside this directory