DEV Community

Discussion on: How I accidentally wrote an awesome HTML Preprocessor

Collapse
 
morgboer profile image
Riaan Pietersen

So if you look at the standard bootstrap3 accordian setup: getbootstrap.com/docs/3.3/javascri... that could be turned into a JSON object, I'm sure. Perhaps something like this:

{
content:{
"First tab":"

This is potentially the content of my first tab

",
"Second tab":"

This is potentially the content of my second tab

",
"Third tab":"

This is potentially the content of my third tab

"
},
settings: {
"setting1":true,
"setting2":"a value"
}
}

Your parser could interpret a shortcode with a json parameter to quickly build the entire structure of the accordian very quickly and cleverly. Perhaps you could allow for passing in variables/settings like in the json above. It could potentially work for any of the preset Bootstrap components, I think?

Thread Thread
 
nektro profile image
Meghan (she/her)
Thread Thread
 
morgboer profile image
Riaan Pietersen

That's it! Could it be envoked inline, like the other replacements, through some sort of a tag? This seems quite specific with a lot of javascript triggering it?

Thread Thread
 
nektro profile image
Meghan (she/her)

Importing the code from bs4-accordion.html just once, <bs4-accordion> becomes a tag available anywhere in the document. The slightly monotonous init JS is because of the specificity of Bootstrap syntax but with the Custom Element it sets all that up for you.

Thread Thread
 
morgboer profile image
Riaan Pietersen • Edited

Sounds ideal then :)

Have you looked at riot.js? Perhaps some knowledge to glean from there too.

Are you happy with it?