Nyhan Nyhan - 1 month ago 14
Python Question

How do I operate jinja html files

I've a new subscription business and I'm using Cratejoy. I downloaded one of their themes through ftp so that I could edit it more easily, and found out that they use Jinja2 templating.

So I went out installed python and installed jinja2, but I'm at a standstill. I have no idea, and I've been googling for the night, on how to get these html files that have jinja working. When I go to run the index html page on chrome, like I would with a typical html page, none of it works. Here's a screenshot.

enter image description here

Can someone please point me in the right direction with this? I want to be able to run all the web pages in chrome the same way they look like when I run them from within the cratejoy environment. Does jinja need some sort of environment?

Answer

Jinja 2 templates are source code files from which HTML files are built. You need to have some sort to processor which takes in Jinja 2 files and creates HTML files for them.

  • Script takes context parameters as input

  • Script reads Jinja 2 files, fill in the context info

  • Script outputs generated HTML files

CrateJoy documentation does not seem to offer any such script, toolbox or example which allows you to process the templates disconnected from actual live CrateJoy system. Looks like all processing is internal to their system and they do not wish to expose it. One could reverse engineer their template processing, but it is non-trivial amount of work. I suggest you write to CrateJoy support and inform them their template creation tools are not sufficient.

Comments