SimonBiggs / scriptedforms

Quickly create live-update GUIs for Python packages using Markdown and simple HTML elements.
Apache License 2.0
508 stars 34 forks source link

Implement Jinja2 -- Determine template variables #255

Closed SimonBiggs closed 6 years ago

SimonBiggs commented 6 years ago

At beginning need to determine all of the variables that impact the template. If any of those variables change the template needs to be rerun.

https://stackoverflow.com/questions/8260490/how-to-get-list-of-all-variables-in-jinja-2-templates

from jinja2 import Environment, PackageLoader, meta
env = Environment(loader=PackageLoader('gummi', 'templates'))
template_source = env.loader.get_source(env,   'page_content.html')[0]
parsed_content = env.parse(template_source)
meta.find_undeclared_variables(parsed_content)
SimonBiggs commented 6 years ago

I'm planning on implementing Jinja over the entire form. See

https://raw.githubusercontent.com/SimonBiggs/scriptedforms/master/scriptedforms/docs/docs-base.md and https://raw.githubusercontent.com/SimonBiggs/scriptedforms/master/scriptedforms/docs/landing-page.md

for an example of how this implementation might be used.

SimonBiggs commented 6 years ago

Plan on implementing this alongside writing the docs with the aim to make ScriptedForms flexible enough to be used to write its own documentation.

SimonBiggs commented 6 years ago

The more I think about it... the more I think Jinja isn't the way to go here. I should be leaning on Angular instead...