Skip to content
Snippets Groups Projects
Commit 3508f9d2 authored by unknown's avatar unknown
Browse files

partie b finie

parent 99faab93
Branches
No related tags found
No related merge requests found
const data = [ const data = [
{ {
name: "Regina", name: 'Regina',
base: "tomate", base: 'tomate',
price_small: 6.5, price_small: 6.5,
price_large: 9.95, price_large: 9.95,
image: image:
"https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300", 'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300',
}, },
{ {
name: "Napolitaine", name: 'Napolitaine',
base: "tomate", base: 'tomate',
price_small: 6.5, price_small: 6.5,
price_large: 8.95, price_large: 8.95,
image: image:
"https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300", 'https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300',
}, },
{ {
name: "Spicy", name: 'Spicy',
base: "crème", base: 'crème',
price_small: 5.5, price_small: 5.5,
price_large: 8, price_large: 8,
image: image:
"https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300", 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300',
}, },
]; ];
class Component {
constructor(tagName, param = '', children = null) {
this.tagName = tagName;
this.param = param;
this.children = children;
}
render() {
let param = '';
if (this.param.name !== undefined || this.param.value !== undefined)
param = `${this.param.name}="${this.param.value}"`;
if (this.children === null) return `<${this.tagName} ${param}/>`;
return `<${this.tagName} ${param}> ${this.children} </${this.tagName}>`;
}
}
class img extends Component {
constructor(param) {
super('img', param);
}
}
const title = new Component('img', { name: 'src', value: data[0].image });
console.log(title.render());
document.querySelector('.pageTitle').innerHTML = title.render();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment