Edge Template Basics
Explore how to use Edge templating syntax in AdonisJs to display variables, render raw HTML, and include built-in tags like conditionals and loops. Understand how Edge integrates with controllers and views to build dynamic web pages.
We'll cover the following...
We'll cover the following...
Edge uses double curly braces {{}} as a basic template to display variables. It also escapes and does not render any HTML tags. To render raw HTML tags, we must use the triple curly braces {{{}}}. These concepts are demonstrated in the code below:
Displaying a variable and rendering raw HTML
'use strict'
class TestController {
//Extracting the view class of the HTTP context
edge({ view }) {
return view.render('test', {
content: 'Passing from Controller' })
}
}
module.exports = TestControllerPress Run and wait for the output to be displayed in the Output tab to see the code in action. ...