Skip to content

Commit

Permalink
LDBR-2.9: Изменить способ компиляции шаблонов Handlebars (#18)
Browse files Browse the repository at this point in the history
* LDBR-2.9: Изменить способ компиляции шаблонов Handlebars.

* LDBR-2.9: Исправить импорты tmpl.js. Исправить загрузку tmpl.js.

* LDBR-2.9: Удалить лишний отступ.
  • Loading branch information
DPeshkoff authored Oct 11, 2021
1 parent 8c7d4b1 commit 2de12b2
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 45 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#npm modules
node_modules/*

#hbs templates
#hbs compiled templates
tmpl.js
*.tmpl.js

#ds store
.DS_Store

#ide
.idea
6 changes: 0 additions & 6 deletions handlebars.sh

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ladnodavaytebezroflov-frontend",
"version": "0.0.9",
"version": "0.1.0",
"description": "LadnoDavayteBezRoflov team, Technopark, autumn of 2021",
"main": "./server/server.js",
"scripts": {
"handlebars": "./handlebars.sh",
"handlebars": "npx handlebars ./src/ -f ./src/tmpl.js --extension \"hbs\"",
"server": "node server/server.js",
"start": "npm run handlebars && npm run server",
"lint": "npx eslint . --ext .js",
Expand Down
5 changes: 1 addition & 4 deletions src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Базовый компонент
import BaseComponent from '../BaseComponent.js';

// Скомпилированный шаблон Handlebars
import './Footer.tmpl.js';

/**
* Класс, реализующий компонент Footer.
*/
Expand All @@ -18,7 +15,7 @@ export default class FooterComponent extends BaseComponent {
*/
constructor(parent, context) {
super(parent, context);
this.renderComponent = Handlebars.templates['Footer.hbs'];
this.renderComponent = Handlebars.templates['components/Footer/Footer'];
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Базовый компонент
import BaseComponent from '../BaseComponent.js';

// Скомпилированный шаблон Handlebars
import './Navbar.tmpl.js';

/**
* Класс, реализующий компонент Navbar.
*/
Expand All @@ -18,7 +15,7 @@ export default class NavbarComponent extends BaseComponent {
*/
constructor(parent, context) {
super(parent, context);
this.renderComponent = Handlebars.templates['Navbar.hbs'];
this.renderComponent = Handlebars.templates['components/Navbar/Navbar'];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use strict';

// utils
import {registerPartials} from './utils/Partials/partials.js';
import {Html, Urls} from './utils/constants.js';
import router from './utils/Router/Router.js';
import userStatus from './utils/UserStatus/UserStatus.js';

// Скомпилированные шаблон Handlebars
import '/src/tmpl.js';

// Контроллеры
import RegisterController from './controllers/RegisterController/RegisterController.js';
import LoginController from './controllers/LoginController/LoginController.js';
Expand All @@ -21,8 +23,6 @@ window.addEventListener('DOMContentLoaded', async () => {
await userStatus.init();
}

registerPartials();

/* Регистрация контроллеров для роутера */
router.registerUrl(Urls.Root, new RegisterController(root)); // placeholder
router.registerUrl(Urls.Register, new RegisterController(root));
Expand Down
5 changes: 1 addition & 4 deletions src/pages/BoardsPage/BoardsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import userStatus from '../../utils/UserStatus/UserStatus.js';
import router from '../../utils/Router/Router.js';
import {Urls} from '../../utils/constants.js';

// Скомпилированный шаблон Handlebars
import './BoardsPage.tmpl.js';

/**
* Класс, реализующий страницу с досками.
*/
Expand All @@ -24,7 +21,7 @@ export default class BoardsPage extends BasePage {
* @param {Element} parent HTML-элемент, в который будет осуществлена отрисовка
*/
constructor(parent) {
super(parent, Handlebars.templates['BoardsPage.hbs']);
super(parent, Handlebars.templates['pages/BoardsPage/BoardsPage']);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/pages/LoginPage/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import router from '../../utils/Router/Router.js';
import Validator from '../../utils/Validator/Validator.js';
import {HttpStatusCodes, Urls} from '../../utils/constants.js';

// Скомпилированный шаблон Handlebars
import './LoginPage.tmpl.js';

/**
* Класс, реализующий страницу с входа.
*/
Expand All @@ -26,7 +23,7 @@ export default class LoginPage extends BasePage {
* @param {Element} parent HTML-элемент, в который будет осуществлена отрисовка
*/
constructor(parent) {
super(parent, Handlebars.templates['LoginPage.hbs']);
super(parent, Handlebars.templates['pages/LoginPage/LoginPage']);
this.formAuthorizationCallback = this.formAuthorization.bind(this);
}

Expand Down
5 changes: 1 addition & 4 deletions src/pages/RegisterPage/RegisterPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import router from '../../utils/Router/Router.js';
import Validator from '../../utils/Validator/Validator.js';
import {HttpStatusCodes, Urls} from '../../utils/constants.js';

// Скомпилированный шаблон Handlebars
import './RegisterPage.tmpl.js';

/**
* Класс, реализующий страницу регистрации.
*/
Expand All @@ -26,7 +23,7 @@ export default class RegisterPage extends BasePage {
* @param {Element} parent HTML-элемент, в который будет осуществлена отрисовка
*/
constructor(parent) {
super(parent, Handlebars.templates['RegisterPage.hbs']);
super(parent, Handlebars.templates['pages/RegisterPage/RegisterPage']);
this.formRegistrationCallback = this.formRegistration.bind(this);
}

Expand Down
13 changes: 0 additions & 13 deletions src/utils/Partials/partials.js

This file was deleted.

0 comments on commit 2de12b2

Please sign in to comment.