{"id":113710,"date":"2022-04-29T11:00:00","date_gmt":"2022-04-29T08:00:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=113710"},"modified":"2022-04-27T11:58:40","modified_gmt":"2022-04-27T08:58:40","slug":"using-the-ejs-template-in-the-nodejs-application","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html","title":{"rendered":"Using the EJS template in the node.js application"},"content":{"rendered":"<p>Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application.<\/p>\n<h2>1. Introduction<\/h2>\n<p><strong>ejs<\/strong> or Embedded Javascript Templating is a template engine used by nodejs applications. The template engine helps to work on the html code with minimal code. Ejs is one of the most common templating engines used these days that offer important features like \u2013<\/p>\n<ul>\n<li>Control flow with <code>&lt;% %&gt;<\/code> tag<\/li>\n<li>Escaped output with <code>&lt;%= %&gt;<\/code> tag<\/li>\n<li>Unescaped raw output with <code>&lt;%- %&gt;<\/code> tag<\/li>\n<li>Newline-trim mode with <code>-%&gt;<\/code> ending tag<\/li>\n<li>Etc<\/li>\n<\/ul>\n<p>Ejs provides several tags such as \u2013<\/p>\n<ul>\n<li><code>&lt;%<\/code> = Scriptlet tag, for control flow, no output<\/li>\n<li><code>&lt;%_<\/code> = Whitespace Slurping Scriptlet tag, strips all whitespace before it<\/li>\n<li><code>&lt;%=<\/code> = Outputs the value into the template (escaped)<\/li>\n<li><code>&lt;%-<\/code> = Outputs the unescaped value into the template<\/li>\n<li><code>&lt;%#<\/code> = Comment tag, no execution, no output<\/li>\n<li><code>&lt;%%<\/code> = Outputs a literal &lt;%<\/li>\n<li><code>%%&gt;<\/code> = Outputs a literal %&gt;<\/li>\n<li><code>%&gt;<\/code> = Plain ending tag<\/li>\n<li><code>-%&gt;<\/code> = Trim-mode (newline slurp) tag, trims the following newline<\/li>\n<li><code>_%&gt;<\/code> = Whitespace Slurping ending tag, removes all whitespace after it<\/li>\n<\/ul>\n<p>Refer to the documentation <a href=\"https:\/\/github.com\/mde\/ejs\/blob\/master\/docs\/syntax.md\" target=\"_blank\" rel=\"noopener\">here<\/a> for a complete list. The below code snippet shows a basic example of it \u2013<\/p>\n<p><span style=\"text-decoration: underline\"><em>Code snippet<\/em><\/span><\/p>\n<pre class=\"brush:html;\">&lt;% if (student) { %&gt;\n  &lt;p&gt;&lt;%= student.name %&gt;&lt;\/p&gt;\n&lt;% } %&gt;\n<\/pre>\n<h3>1.1 Setting up Node.js<\/h3>\n<p>To set up <strong>Node.js<\/strong> on windows you will need to download the installer from <a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noopener\">this<\/a> link. Click on the installer (also include the NPM package manager) for your platform and run the installer to start with the Node.js setup wizard. Follow the wizard steps and click on Finish when it is done. If everything goes well you can navigate to the command prompt to verify if the installation was successful as shown in Fig. 1.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/node-npm-installation-img1-2.jpg\"><img decoding=\"async\" width=\"480\" height=\"91\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/node-npm-installation-img1-2.jpg\" alt=\"\" class=\"wp-image-113711\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/node-npm-installation-img1-2.jpg 480w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/node-npm-installation-img1-2-300x57.jpg 300w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><figcaption>Fig. 1: Verifying node and npm installation<\/figcaption><\/figure>\n<\/div>\n<h2>2. Using the EJS template in the nodejs application<\/h2>\n<p>To set up the application, we will need to navigate to a path where our project will reside and I will be using <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a> as my preferred IDE. Let a take a quick peek at the project structure &#8211;<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectstructureguideimg1.jpg\"><img decoding=\"async\" width=\"380\" height=\"131\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectstructureguideimg1.jpg\" alt=\"\" class=\"wp-image-113713\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectstructureguideimg1.jpg 380w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectstructureguideimg1-300x103.jpg 300w\" sizes=\"(max-width: 380px) 100vw, 380px\" \/><\/a><figcaption>Fig. 2: Project structure<\/figcaption><\/figure>\n<\/div>\n<h3>2.1 Setting up dependencies<\/h3>\n<p>Navigate to the project directory and run <code>npm init -y<\/code> to create a <code>package.json<\/code> file. This <a href=\"https:\/\/docs.npmjs.com\/creating-a-package-json-file\" target=\"_blank\" rel=\"noopener\">file<\/a> holds the metadata relevant to the project and is used for managing the project dependencies, script, version, etc. Replace the generated file with the code given below &#8211;<\/p>\n<p><span style=\"text-decoration: underline\"><em>package.json<\/em><\/span><\/p>\n<pre class=\"brush:json;\">{\n  \"name\": \"ejs\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Understanding ejs in nodejs application\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"dev\": \"nodemon index.js\",\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n  },\n  \"keywords\": [\n    \"ejs\",\n    \"nodemon\",\n    \"nodejs\",\n    \"expressjs\",\n    \"jcg\",\n    \"practice\"\n  ],\n  \"author\": \"geek\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"ejs\": \"^3.1.7\",\n    \"express\": \"^4.17.3\"\n  },\n  \"devDependencies\": {\n    \"nodemon\": \"^2.0.15\"\n  }\n}\n<\/pre>\n<p>Once the file is replaced trigger the below <code>npm<\/code> command in the terminal window to download the different packages required for this tutorial.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Downloading dependencies<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">npm install\n<\/pre>\n<h3>2.2 Setting up the template page<\/h3>\n<p>Create a file inside the <code>views<\/code> responsible to show the students&#8217; information received from the backend endpoint.<\/p>\n<p><span style=\"text-decoration: underline\"><em>views\/students.ejs<\/em><\/span><\/p>\n<pre class=\"brush:html;\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;title&gt;Ejs&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;&lt;%= title %&gt;&lt;\/h1&gt;\n    &lt;% if (students &amp;&amp; students.length &gt; 0) { %&gt;\n    &lt;ul&gt;\n      &lt;% students.forEach((item, index) =&gt; { %&gt;\n      &lt;li&gt;#&lt;%= (index + 1) %&gt;&lt;\/li&gt;\n      &lt;li&gt;Name: &lt;%= item.name %&gt;&lt;\/li&gt;\n      &lt;li&gt;Email: &lt;%= item.email %&gt;&lt;\/li&gt;\n      &lt;% if (item.hobbies &amp;&amp; item.hobbies.length &gt; 0) { %&gt;\n      &lt;li&gt;\n        Hobbies are:\n        &lt;ul&gt;\n          &lt;% item.hobbies.forEach((hobby) =&gt; { %&gt;\n          &lt;li&gt;&lt;%= hobby %&gt;&lt;\/li&gt;\n          &lt;% }) %&gt;\n        &lt;\/ul&gt;\n      &lt;\/li&gt;\n      &lt;% } else { %&gt;\n      &lt;li&gt;No hobbies found.&lt;\/li&gt;\n      &lt;% } %&gt;\n      &lt;br \/&gt;\n      &lt;br \/&gt;\n      &lt;% }) %&gt;\n    &lt;\/ul&gt;\n    &lt;% } else { %&gt;\n    &lt;p&gt;No students found.&lt;\/p&gt;\n    &lt;% } %&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<h3>2.3 Setting up the implementation file<\/h3>\n<p>Create a file responsible to describe the implementation. The file will be responsible to expose an endpoint that will return the result to the ejs template (<code>students.ejs<\/code>). For simplicity, the endpoint will be sending the mock student\u2019s data but in real work applications, the data will be fetched from the database.<\/p>\n<p><span style=\"text-decoration: underline\"><em>index.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">const express = require(\"express\");\n\nlet app = express();\n\napp.set(\"view engine\", \"ejs\");\n\n\/\/ http get endpoint - http:\/\/localhost:3005\/\n\/\/ shows the result on the students.ejs page\napp.get(\"\/\", (req, res) =&gt; {\n  const data = [\n    {\n      name: \"John doe\",\n      email: \"john.doe@test.com\",\n      hobbies: [\"Cricket\", \"Football\", \"Swimming\"]\n    },\n    {\n      name: \"Adam doe\",\n      email: \"adam.joe@test.com\",\n      hobbies: [\"Football\", \"Table Tennis\", \"Tennis\", \"Badminton\"]\n    },\n    {\n      name: \"Oliver james\",\n      email: \"oliver.james@test.com\",\n      hobbies: []\n    },\n    {\n      name: \"Michael jacob\",\n      email: \"michael.jacob@test.com\",\n      hobbies: [\"Tennis\"]\n    }\n  ];\n\n  res.render(\"students\", {\n    title: \"Student Information\",\n    students: data\n  });\n});\n\n\/\/ driver code\nconst port = 3005;\napp.listen(port, () =&gt; {\n  console.log(`Service endpoint = http:\/\/localhost:${port}`);\n});\n<\/pre>\n<h2>3. Run the Application<\/h2>\n<p>To run the application navigate to the project directory and enter the following command as shown below in the terminal.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Run command<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">$ npm run dev\n<\/pre>\n<p>If everything goes well the application will be started successfully at the service endpoint &#8211; <code>http:\/\/localhost:3005<\/code><\/p>\n<h2>4. Demo<\/h2>\n<p>The application exposes a single endpoint (<code>http:\/\/localhost:3005\/<\/code>). Once the endpoint is hit in the browser the below output will be shown illustrating the ejs template implementation.<\/p>\n<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectdemoguideimg1-1.jpg\"><img decoding=\"async\" width=\"369\" height=\"656\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectdemoguideimg1-1.jpg\" alt=\"\" class=\"wp-image-113714\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectdemoguideimg1-1.jpg 369w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/nodejsejsprojectdemoguideimg1-1-169x300.jpg 169w\" sizes=\"(max-width: 369px) 100vw, 369px\" \/><\/a><figcaption>Fig. 3: Application demo<\/figcaption><\/figure>\n<\/div>\n<p>That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>5. Summary<\/h2>\n<p>In this tutorial, we saw the implementation of ejs template in an express js application. You can download the source code from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>6. Download the Project<\/h2>\n<p>This was a tutorial to implement ejs template in a nodejs and express js application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/04\/Using-the-EJS-template-in-the-nodejs-application.zip\"><strong>Using the EJS template in the nodejs application<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction ejs or Embedded Javascript Templating is a template engine used by nodejs applications. The template engine helps to work on the html code with minimal code. Ejs is one of the &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":20900,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1879],"tags":[991,803,2065],"class_list":["post-113710","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-express-js","tag-javascript","tag-nodejs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the EJS template in the node.js application - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the EJS template in the node.js application - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-29T08:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"Using the EJS template in the node.js application\",\"datePublished\":\"2022-04-29T08:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html\"},\"wordCount\":635,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"keywords\":[\"Express.js\",\"JavaScript\",\"nodejs\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html\",\"name\":\"Using the EJS template in the node.js application - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"datePublished\":\"2022-04-29T08:00:00+00:00\",\"description\":\"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-ejs-template-in-the-nodejs-application.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Using the EJS template in the node.js application\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the EJS template in the node.js application - Java Code Geeks","description":"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html","og_locale":"en_US","og_type":"article","og_title":"Using the EJS template in the node.js application - Java Code Geeks","og_description":"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction","og_url":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2022-04-29T08:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"Using the EJS template in the node.js application","datePublished":"2022-04-29T08:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html"},"wordCount":635,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","keywords":["Express.js","JavaScript","nodejs"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html","url":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html","name":"Using the EJS template in the node.js application - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","datePublished":"2022-04-29T08:00:00+00:00","description":"Hello. In this tutorial, we will understand and see a practical implementation of ejs template in the nodejs and express js application. 1. Introduction","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/using-the-ejs-template-in-the-nodejs-application.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"Using the EJS template in the node.js application"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/113710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=113710"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/113710\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/20900"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=113710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=113710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=113710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}