Page 1 of 1

OctoPrint - Jinja2

Posted: January 15th, 2018, 5:54 pm
by Roberts_Clif
Octoprint uses Jinja2 a central object called the template Environment. In OctoPrint Jinja2 environment is this line in control.jinja2.
<input type="number" style="width: 153px" data-bind="slider: {min: 50, max: 150, step: 1, value: feedRate, tooltip: 'hide'}">

I would like to know if I changed it to this, would it still work only sliding between 30 and 130.
<input type="number" style="width: 153px" data-bind="slider: {min: 30, max: 130, step: 1, value: feedRate, tooltip: 'hide'}">

Or is there more to the Jinja template environment than just changing a line in the template.

I Found this.
To load a template from this environment you just have to call the get_template(Feed rate) method which then returns the loaded Template:
To render it with some variables, just call the print template.render(value: feedRate) method:

Can someone tell me if I am on the rite track.

Re: OctoPrint - Jinja2

Posted: January 16th, 2018, 7:50 pm
by LePaul
Sounds like a question for @nallath

Re: OctoPrint - Jinja2

Posted: January 17th, 2018, 7:01 am
by nallath
I don't know anything about how Octoprint does what it does, sorry. Web development isn't my cup of tea.

Re: OctoPrint - Jinja2

Posted: January 17th, 2018, 9:23 am
by Roberts_Clif
Thank you for responding.

Believe that it is correct as Jinja2 is a full featured template engine for Python, and python is an interpreted language.

Will do what I do best and self teach myself Jinja2 and Python. It is told that they are the simplest language's to learn, however I believe BASIC was (Beginner's All-Purpose Symbolic Instruction Code). And as a programmer this should make the learning all that much easier.

I have cloned my OctoPrint's SD cards Using the same program that was used to burn to SD card with (Win32DiskImager). This should make recovering from an error simpler. I will now start testing my learning and programming skills.

Have discovered that if Cura Print Speed is set to 40 then the OctoPrint slider control changes the speed accordingly. I Mean it adjusts the speed based on the Set printer speed of 40. 40 being OctoPrint slider 100 percent and 20 would be OctoPrint slider 50 percent making OctoPrint slider 150 percent Printer speed 60.

Re: OctoPrint - Jinja2

Posted: January 17th, 2018, 11:06 am
by Roberts_Clif
P.S.S.

If any one know of a Good web Site to Learn Jinja2 and Python, would appreciate help there also.

Thank You.