What are the ways (technologies) to create a modular html code?

I want to create a collection of elements with the basic layout for future reuse.
Tried BEM project stub, but it didn't go too difficult to configure the assembler by itself (the Assembly of the sprites, compressing images, the structure of the final project, etc.).
Tried TARS, very cool stuff, but the project is poorly developed.
So I decided to make my assembler which will work as I need.
Doing on the pug, but sometimes it turns out all too confusing.
Basic requirements:
- the presence of mixins/functions. For example create component button. In different places of the template it should take different parameters (a different tag, additional classes, data attributes, etc.).
- the ability to separate data from markup, for example to load from a json file or something like that.
- ability to easily extend these mixins/functions. To do nested components (component "icon" inside the component "button").
In a pug it can be done, but it turns out spike.
Can anyone advise a better solution than pug, share useful links, experiences, etc.?
June 5th 19 at 21:49

Find more questions by tags CSSHTML