Friday, February 24, 2017

Jinja templates structure

Hi guys! 

I'm involved in a big Django project and I'm trying to propose a way to organize the big amount of jinja templates that we have in our project. The way I'm proposing to oganize them is following a BEM methodology, where all the pages used by a DjangoView  being in a pages folder, and all the blocks an elements contained in a blocks subfolder. 

In this approach, each block is represented by a jinja template, and all of it's elements and blocks are declared inside a folder with the same name, and modified elements are declared at the same level. So the directory structure good look something like this:



  • pages/
    • home.jinja
    • page1.jinja
    • page2.jinja
  • blocks
  • block/
    • subblock-a/
      • .... (all elements of subblock-a)
    •  subblock-b.jinja
    •  element-a.jinja
    •  element-a__dark.jinja
    •  element-b.jinja
  •  search.jinja
  •  search/ (In case search reusable block has more elements)
  •  block.jinja
So in this example, we have "block" and "search" blocks. "block" having "subblock-a", "subblock-b" as subblocks and element-a, element-b as elements. 

What do you think about this approach? It will be really helpful to have some feedback on it. Thanks! 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4b15b499-4a77-492c-a177-43027c7aaec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment