Skip to content
Snippets Groups Projects
Commit 43eeec15 authored by Mathis Verleene's avatar Mathis Verleene
Browse files

B.

parent 2382e328
No related branches found
No related tags found
No related merge requests found
......@@ -8,39 +8,52 @@ class Component {
this.children = children;
}
render() {
if (typeof children !== 'undefined') {
if (
typeof this.attribute !== 'undefined' &&
typeof this.children !== 'undefined'
) {
return `<${this.tagName} ${this.attribute.name}="${this.attribute.value}" >${this.children}</${this.tagName}`;
}
if (typeof this.children !== 'undefined') {
return `<${this.tagName}>${this.children}</${this.tagName}>`;
}
if (typeof this.attribute !== 'undefined') {
return `<${this.tagName} ${this.attribute.name}="${this.attribute.value}" />`;
}
return `<${this.tagName} />`;
}
}
const img = new Component('img');
class Img extends Component {
constructor(url) {
super('img', { name: 'src', value: url });
}
}
const img = new Img(
'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300'
);
document.querySelector('.pageContent').innerHTML = img.render();
const data = [
{
const data = [{
name: 'Regina',
base: 'tomate',
price_small: 6.5,
price_large: 9.95,
image:
'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300',
image: 'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300',
},
{
name: 'Napolitaine',
base: 'tomate',
price_small: 6.5,
price_large: 8.95,
image:
'https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300',
image: 'https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300',
},
{
name: 'Spicy',
base: 'crème',
price_small: 5.5,
price_large: 8,
image:
'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300',
image: 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300',
},
];
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment