Skip to content

Commit

Permalink
Update handlebars template imports for deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
AshurovG committed Sep 26, 2024
1 parent 0290eff commit 1162860
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion public/components/AuthForm/AuthForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { goToPage } from '../..';
import { apiClient } from '../../modules/ApiClient';
import template from './AuthForm.hbs';

import {
validateEmailAddress,
validatePassword,
Expand Down Expand Up @@ -78,7 +80,6 @@ export class AuthForm {
}

renderTemplate() {
const template = Handlebars.templates['AuthForm.hbs'];
this.#parent.innerHTML = template();
}
}
5 changes: 3 additions & 2 deletions public/components/Card/Card.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import template from './Card.hbs';

export class Card {
#parent;
#movie;
Expand All @@ -12,10 +14,9 @@ export class Card {
}

renderTemplate() {
const template = Handlebars.templates['Card.hbs'];
this.#parent.insertAdjacentHTML(
'beforeend',
template({ movie: this.#movie })
template({ movie: this.#movie }),
);
}
}
3 changes: 1 addition & 2 deletions public/components/CardsList/CardsList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Card } from '../Card/Card';
import template from './CardsList.hbs';

export class CardsList {
#parent;
Expand All @@ -16,8 +17,6 @@ export class CardsList {
}

renderTemplate() {
const template = Handlebars.templates['CardsList.hbs'];

this.#parent.insertAdjacentHTML('beforeend', template({ id: this.#id }));

const cardsList = document.getElementById(`cards-list-${this.#id}`);
Expand Down
3 changes: 2 additions & 1 deletion public/components/ConfirmModal/ConfirmModal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import template from './ConfirmModal.hbs';

export class ConfirmModal {
#text;
#onConfirm;
Expand All @@ -10,7 +12,6 @@ export class ConfirmModal {
}

render() {
const template = Handlebars.templates['ConfirmModal.hbs'];
const root = document.getElementById('root');
root.insertAdjacentHTML('beforeend', template({ text: this.#text }));
root.style.overflow = 'hidden';
Expand Down
2 changes: 1 addition & 1 deletion public/components/GridBlock/GridBlock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CategoryPage } from '../../pages/CategoryPage/CategoryPage';
import template from './GridBlock.hbs';

export class GridBlock {
#parent;
Expand Down Expand Up @@ -31,7 +32,6 @@ export class GridBlock {
}

renderTemplate() {
const template = Handlebars.templates['GridBlock.hbs'];
this.#parent.innerHTML = template({
items: this.getTop(),
title: this.#blockTitle,
Expand Down
3 changes: 2 additions & 1 deletion public/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import template from './Header.hbs';

export class Header {
#parent;
#config;
Expand Down Expand Up @@ -25,7 +27,6 @@ export class Header {
}

renderTemplate() {
const template = Handlebars.templates['Header.hbs'];
const items = this.items.map(([key, { text, href }], index) => {
let className = '';
if (index === 0) {
Expand Down
3 changes: 2 additions & 1 deletion public/components/Loader/Loader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import template from './Loader.hbs';

export class Loader {
// parent нужен для того, чтобы понимать где отображать лоадер
#parent;
Expand All @@ -10,7 +12,6 @@ export class Loader {
}

render() {
const template = Handlebars.templates['Loader.hbs'];
this.#parent.innerHTML = template();
}

Expand Down
2 changes: 1 addition & 1 deletion public/components/RegForm/RegForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { goToPage } from '../..';
import { apiClient } from '../../modules/ApiClient';
import template from './RegForm.hbs';

import {
validateEmailAddress,
Expand Down Expand Up @@ -119,7 +120,6 @@ export class RegForm {
}

renderTemplate() {
const template = Handlebars.templates['RegForm.hbs'];
this.#parent.innerHTML = template();
}
}
3 changes: 1 addition & 2 deletions public/components/Slider/Slider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Card } from '../Card/Card';
import template from './Slider.hbs';

export class Slider {
#parent;
Expand Down Expand Up @@ -37,8 +38,6 @@ export class Slider {
}

renderTemplate() {
const template = Handlebars.templates['Slider.hbs'];

this.#parent.insertAdjacentHTML('beforeend', template({ id: this.#id }));

const container = document.querySelector('.slider__container');
Expand Down
2 changes: 1 addition & 1 deletion public/pages/AuthPage/AuthPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AuthForm } from '../../components/AuthForm/AuthForm';
import template from './AuthPage.hbs';

export class AuthPage {
#parent;
Expand All @@ -16,7 +17,6 @@ export class AuthPage {
rootElem.classList.remove('root-black');
rootElem.classList.add('root-image');

const template = Handlebars.templates['AuthPage.hbs'];
this.#parent.innerHTML = template();

const authForm = document.getElementById('auth-page-form-block');
Expand Down
2 changes: 1 addition & 1 deletion public/pages/CategoryPage/CategoryPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CardsList } from '../../components/CardsList/CardsList';
import { apiClient } from '../../modules/ApiClient';
import { MainPage } from '../MainPage/MainPage';
import template from './CategoryPage.hbs';

export class CategoryPage {
#parent;
Expand Down Expand Up @@ -43,7 +44,6 @@ export class CategoryPage {
}

renderTemplate() {
const template = Handlebars.templates['CategoryPage.hbs'];
this.#parent.innerHTML = template({
title: this.#pageTitle,
});
Expand Down
2 changes: 1 addition & 1 deletion public/pages/MainPage/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CardsList } from '../../components/CardsList/CardsList';
import { GridBlock } from '../../components/GridBlock/GridBlock';
import { Slider } from '../../components/Slider/Slider';
import { Loader } from '../../components/Loader/Loader';
import template from './MainPage.hbs';

import bb from '../../assets/mockImages/bb2.jpg';
import mh from '../../assets/mockImages/mh.jpg';
Expand Down Expand Up @@ -95,7 +96,6 @@ export class MainPage {
rootElem.classList.add('root-black');
rootElem.classList.remove('root-image');

const template = Handlebars.templates['MainPage.hbs'];
this.#parent.innerHTML = template();

this.#loader = new Loader(this.#parent, template());
Expand Down
2 changes: 1 addition & 1 deletion public/pages/RegPage/RegPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RegForm } from '../../components/RegForm/RegForm';
import template from './RegPage.hbs';

export class RegPage {
#parent;
Expand All @@ -16,7 +17,6 @@ export class RegPage {
rootElem.classList.remove('root-black');
rootElem.classList.add('root-image');

const template = Handlebars.templates['RegPage.hbs'];
this.#parent.innerHTML = template();

const regForm = document.getElementById('reg-page-form-block');
Expand Down

0 comments on commit 1162860

Please sign in to comment.