On Jan 18, 8:57 am, cjrh <[email protected]> wrote:
> On Jan 18, 2:13 am, Massimo Di Pierro <[email protected]>
> wrote:
>
> > this is not possible because includes and extends must be resolved
> > before compilation, not at runtime
>
> I have been thinking about this for a while. In principle, it should
> be possible to have the compiled version be able to read, at runtime,
> the script to be included. It really just means that the code works a
> little differently, e.g. a regular python app that either has the name
> of a data file hard-coded into source which then ends up inside the
> pyc, compared to a slightly modified python app that has code to read
> the name of the data file as a run-time input, in which case the name
> of the data file is not included statically inside the pyc.
>
> ...
Thank you for your comments!
For now the following workaround in the layout.html view allows for
compilation and still fulfills the function that I wanted, but it
feels a little bulky...
{{if session.language!=None:}}
{{#need this construct for precompiling the app}}
{{if session.language == 'DE':}}
{{include 'pageheader_DE.html'}}
{{elif ...:}}
{{...}}
{{else:}}
{{include 'pageheader_EN.html'}}
{{pass}}
{{else:}}
{{if session.preferredLanguage == 'DE':}}
{{include 'pageheader_DE.html'}}
{{elif ...:}}
{{...}}
{{else:}}
{{include 'pageheader_EN.html'}}
{{pass}}
{{pass}}