Commit
This commit is contained in:
18
32/app.js
Normal file
18
32/app.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const express = require('express');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
app.use('/contact', function (request, response) {
|
||||
response.render('contact', {
|
||||
title: 'Мои контакты',
|
||||
emailsVisible: true,
|
||||
emails: ['gavgav@mycorp.com', 'mioaw@mycorp.com'],
|
||||
phone: '+1234567890',
|
||||
});
|
||||
});
|
||||
app.use('/', function (request, response) {
|
||||
response.send('Главная страница');
|
||||
});
|
||||
app.listen(3000);
|
||||
1325
32/package-lock.json
generated
Normal file
1325
32/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
32/package.json
Normal file
9
32/package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.2",
|
||||
"ejs": "^3.1.9",
|
||||
"express": "^4.18.2",
|
||||
"express-handlebars": "^7.1.2",
|
||||
"hbs": "^4.2.0"
|
||||
}
|
||||
}
|
||||
23
32/views/contact.ejs
Normal file
23
32/views/contact.ejs
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%=title %></title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1><%=title %> в EJS</h1>
|
||||
|
||||
<% if(emailsVisible) {%>
|
||||
<h3>Электронные адреса</h3>
|
||||
<ul>
|
||||
<% for(var i=0; i<emails.length;i++) {%>
|
||||
<li><%=emails[i] %></li>
|
||||
<%} %>
|
||||
</ul>
|
||||
<% }else {%>
|
||||
<h3>Электронный адрес отсутствует</h3>
|
||||
<%} %>
|
||||
<p>Телефон: <%=phone %></p>
|
||||
</body>
|
||||
<html>
|
||||
3
32/views/contact.hbs
Normal file
3
32/views/contact.hbs
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>{{title}}</h1>
|
||||
<p>Электронный адрес: {{email}}</p>
|
||||
<p>Телефон: {{phone}}</p>
|
||||
10
32/views/home.hbs
Normal file
10
32/views/home.hbs
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Главная страница</h1>
|
||||
</body>
|
||||
<html>
|
||||
14
32/views/layout.hbs
Normal file
14
32/views/layout.hbs
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
{{> menu}}
|
||||
|
||||
{{{body}}}
|
||||
|
||||
{{> footer}}
|
||||
</body>
|
||||
<html>
|
||||
1
32/views/partials/footer.ejs
Normal file
1
32/views/partials/footer.ejs
Normal file
@@ -0,0 +1 @@
|
||||
<footer><p>MyCorp - Copyright © 2017</p></footer>
|
||||
1
32/views/partials/footer.hbs
Normal file
1
32/views/partials/footer.hbs
Normal file
@@ -0,0 +1 @@
|
||||
<footer><p>MyCorp - Copyright © 2017</p></footer>
|
||||
4
32/views/partials/menu.ejs
Normal file
4
32/views/partials/menu.ejs
Normal file
@@ -0,0 +1,4 @@
|
||||
<nav>
|
||||
<a href="/">Главная</a> |
|
||||
<a href="/contact">Контакты</a>
|
||||
</nav>
|
||||
4
32/views/partials/menu.hbs
Normal file
4
32/views/partials/menu.hbs
Normal file
@@ -0,0 +1,4 @@
|
||||
<nav>
|
||||
<a href="/">Главная</a> |
|
||||
<a href="/contact">Контакты</a>
|
||||
</nav>
|
||||
Reference in New Issue
Block a user