Jinja templates structure

35 views
Skip to first unread message

Guillermo Gonzalez

unread,
Feb 24, 2017, 1:59:50 PM2/24/17
to Django users
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! 
Reply all
Reply to author
Forward
0 new messages