Author - StudySection Post Views - 1,116 views
Templating

What are Templating Engines?

Engines


A template processor (also referred to as a template engine or template parser) is software designed to mix templates with a knowledge model to supply result documents.

The language that the templates are written in is understood as a template language or templating language.

In simple words, A template engine is a mechanism that enables you to use static template files in your application.
Template engine replaces the variables inside a web template file with actual values(at runtime), and transforms the template into an HTML file sent to the client with the dynamic data. This technique makes it easier to style an HTML page.

From the below diagram the functionality of Templating Engines is clear i.e. how the data from the database are shown on the HTML page dynamically.


template-page1

Some commonly used Templating Engines with examples.

Blade Template: You may display data that is passed to your Blade views(HTML) by wrapping the variable in curly braces. For example, given the below route:
Route::get('/', function () {
return view('welcome', ['name' => 'Samantha']);
});

You may also display the contents of the name variable like so:
Hello, {{ $name }}.

Blade’s {{ }} echo statements are automatically sent through PHP’s htmlspecialchars function to stop XSS attacks.

EJS(Embedded JavaScript templating):

Embedded Javascript Templating is a templating engine used in Node.js.

EJS is a simple templating language that is used to create the HTML markup with plain JavaScript.
<% if (user) { %>
<h2><%= user.name %></h2>
<% } %>

Pug:
Pug in node. js is a template engine that uses case-sensitive syntax to create HTML, in other words, it returns a string of HTML rendered as per data identified in a pug file. We can say that pug is a middleman who plays a task to convert the injected data and translate it into HTML syntax
doctype html
html(lang='en')
head
title Hello, World!
body
h1 Hello, World!
div.remark
p Pug rocks!

Get certification for your knowledge in the fundamentals of Computer functioning by clearing the Computer Certification Exam conducted by StudySection. After going through this Computer Certification Exam, you will be able to evaluate your basic knowledge of computers.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri