{{#eachthis.cards}} I have the following code (using Handlebars, working code from JSFiddle): {{title}} Basically, it loops through the array of cards and creates a This all works as expected and visually gives the desired UI (regardless of the number of cards): Example below: However, as shown in the JSON, I need a property outside of the individual card level to determine whether the desktop should break from a 4-column layout to a 3-column layout. I didn't want to repeat this property for every card in the card array, so reorganized my code as shown in my code snippet (using Handlebars): https://jsfiddle.net/stcfa5wh/20/< ;/p > However, this now means that although I can access the For example, on a tablet, I could set each Can anyone suggest a way to preserve the structure of the HTML while still implementing top-level attributes (e.g. { "3columnLayout": false, "cards": [ { "title": "Card 1" }, { "title": "Card 2" }, { "title": "Card 3" } ] }
card-container
div for each item. Then use bootstrap to assign a CSS class to each div, for example col-md-6
so that:
3columnLayout
value: the HTML is dumped onto the page, and I can no longer use col
in the way I do ;Done before. image-card
to 50% width, but it ignores the need for rows. 3columnLayout
)?
I don't understand why you stopped using Bootstrap when you tried to implement the
3columnLayout
flag. Using Bootstrap, we will create a 3 column layout using classcol-lg-4
on each column. Therefore, the conditional expression we need for each column is:{{#if ../3columnLayout}}col-lg-4{{else}}col-lg-3{{/if}}
.