Add compiler setting titleCaseClassNames - #74
Conversation
44e8cca to
9c1a3ab
Compare
The class name of a compiled template is its module name, so my_template.tmpl defines the class my_template. With the setting turned on it defines MyTemplate. The implicit import of #extends follows the setting: `#extends my_base` does `from my_base import MyBase`. The name in the directive is still the module name. A name that is already in title case comes through unchanged, so `Cheetah.Templates.SkeletonPage.SkeletonPage` still imports SkeletonPage, and a class imported explicitly is left alone. Template.compile() and loadTemplateClass() now ask for the class name the compiler used instead of assuming it equals the module name. A compilerClass of one's own need not implement the new method. A name that would turn into a Python keyword gets a trailing underscore, since class None(Template) is a syntax error. The setting is read once, before parsing, so a #compiler-settings directive has no effect on it. Reading it live would rename the base class in the #extends import but not the class of the template itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
9c1a3ab to
4b66157
Compare
|
Hello! Thank you for the hard work on Cheetah! Unfortunately I have personal problems that prevent me to look deeper. I'm preparing for eye surgery. I hope to recover in October. Will be back when I will have better eyesight. |
|
Hello Oleg, thank you for the update and for all your work on Cheetah. I’m sorry to hear you are going through personal health challenges, and I hope the eye surgery goes smoothly and that your recovery in October is steady and comfortable. Wishing you all the best during this time. In the meantime, would they prefer that I take over any responsibilities related to this PR, or should I simply wait until you are back and able to review things again?
Manuel
Gesendet von Outlook für iOS<https://aka.ms/o0ukef>
…________________________________
Von: Oleg Broytman ***@***.***>
Gesendet: Saturday, 29 August 2026 17:07:01
An: CheetahTemplate3/cheetah3 ***@***.***>
Cc: hilman2 ***@***.***>; Author ***@***.***>
Betreff: Re: [CheetahTemplate3/cheetah3] Add compiler setting titleCaseClassNames (PR #74)
[https://avatars.githubusercontent.com/u/730158?s=20&v=4]phdru left a comment (CheetahTemplate3/cheetah3#74)<#74 (comment)>
Hello! Thank you for the hard work on Cheetah! Unfortunately I have personal problems that prevent me to look deeper. I'm preparing for eye surgery. I hope to recover in October. Will be back when I will have better eyesight.
—
Reply to this email directly, view it on GitHub<#74?email_source=notifications&email_token=ATANMXIYDB6ZN3Q2NAJLHJD5MLWRLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBWGMYTINJWGE22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5463145615>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ATANMXJBNY3RNGZ5YI6LN5T5MLWRLAVCNFSNUABFKJSXA33TNF2G64TZHMYTANZTGI3TEMZTHNEXG43VMU5TKMRVHA4DKMRTGQ3KC5QC>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Thank you very much!
There're not much of "they" left in the project. I'm afraid I'm the only reviewer here.
|
Closes #67.
With the setting on,
my_template.tmplcompiles toclass MyTemplate, and#extends my_basedoesfrom my_base import MyBase. The name in#extendsstays the module name. A name that is already in title case comes through unchanged, soCheetah.Templates.SkeletonPage.SkeletonPagestill importsSkeletonPage, and a class imported explicitly is not touched.Template.compile()andloadTemplateClass()ask the compiler for the class name it used instead of assuming it equals the module name. AcompilerClassof one's own does not have to implement the new method.The setting is read once, before parsing, so a
#compiler-settingsdirective does not reach it. Reading it live would rename the base class in the#extendsimport but not the class of the template itself.--settings,compilerSettings=and_CHEETAH_compilerSettingsall work, and the docs say so.Default is off.
21 new tests in
Cheetah/Tests/ClassNames.py, among them one that compiles a base and a derived template and renders it, and one forloadTemplateClass. Full suite passes on 2.7, 3.6 and 3.12, flake8 clean, docs build clean.