Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for loop mecanism #10

Open
AbcSxyZ opened this issue Aug 8, 2020 · 7 comments
Open

for loop mecanism #10

AbcSxyZ opened this issue Aug 8, 2020 · 7 comments

Comments

@AbcSxyZ
Copy link

AbcSxyZ commented Aug 8, 2020

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.

@lingster
Copy link
Owner

lingster commented Aug 8, 2020

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

@AbcSxyZ
Copy link
Author

AbcSxyZ commented Aug 8, 2020

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

@lingster
Copy link
Owner

lingster commented Aug 8, 2020

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.

@AbcSxyZ
Copy link
Author

AbcSxyZ commented Aug 8, 2020

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
Copy link
Author

AbcSxyZ commented Aug 8, 2020

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.

@lingster
Copy link
Owner

lingster commented Aug 8, 2020

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

@AbcSxyZ
Copy link
Author

AbcSxyZ commented Aug 8, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants