django-bootstrap-studio-tools icon indicating copy to clipboard operation
django-bootstrap-studio-tools copied to clipboard

for loop mecanism

Open AbcSxyZ opened this issue 5 years ago • 7 comments

I was wondering when you are working on BSS and creating dj-for element, inside BSS you will have a single element ?

Imagine it's for single column, you create the first one with dj-for, and that's all ? You can't get multiples columns in BSS to see how it looks like ?

Seem to work like that, but would be great to have in BSS an overview of what it will look like with generate data of a loop.

AbcSxyZ avatar Aug 08 '20 08:08 AbcSxyZ

Not sure I fully understand your query. Could you elaborate? Is the query about having a nested dj-for loops inside BSS?

lingster avatar Aug 08 '20 08:08 lingster

A for loop is to generate mutliple element. In you bss file, you have a for loop containing only a single element right of the loop ? So in bss for exemple, instead of seeing multiples columns, you must have only one column to create a proper loop, right ? Hope I was clear

AbcSxyZ avatar Aug 08 '20 09:08 AbcSxyZ

yes that's right, so if you look at the example bss html file:

<div class="item" dj-for="i in items">
  <h2 dj-ref="i.name">This is the heading</h2>
  <div dj-ref="i.content|markdown">Lorem ipsum dolor sit amet …</div>
</div>

You only need to define a single element of the for..loop and the export script will expand the html into the django template as follows:

{% for i in items %}
  <div class="item">
   <h2>
    {{ i.name }}
   </h2>
   <div>
    {{ i.content|markdown }}
   </div>
  </div>
  {% endfor %}

The django template rendering engine will take care of iterating though the items(supplied via get_context) and will expand that out into many elements.

lingster avatar Aug 08 '20 09:08 lingster

So in this way you won't have an overview of the final rendering inside bss ? You must use django template system to see it.

AbcSxyZ avatar Aug 08 '20 09:08 AbcSxyZ

It could have been great to have an this overview in BSS, I thought about it, but it could be a bit a headache to differentiate element of the loop.

AbcSxyZ avatar Aug 08 '20 09:08 AbcSxyZ

BSS won't know how to fully render django templates, so the workflow is to design the django template using BSS, then pass the converted file into django and render it to see the final result

lingster avatar Aug 08 '20 09:08 lingster

Sure, it would be done with some fake data in BSS. It would avoid switching to django server to see any modification. I understand what you expected to do. I didn't use your program actually, I'm wondering what's the most convenient.

Thx for reply

AbcSxyZ avatar Aug 08 '20 09:08 AbcSxyZ