[ANN] HTMLTemplate 1.0.0

Eric S. Johansson esj at harvee.org
Wed Jun 2 12:00:07 EDT 2004


David Fraser wrote:

> It looks cool because it doesn't embed Python code in the template.
> Do any of the other frameworks have this approach?

opagcgilib.py is a simple look for %%key%% in dictionary and substitute 
  value type of template tool.  Which, quite frankly, is enough for me. 
  All of the embedded python whoo-ha is just more of a barrier than 
anything else.

Every time some bright puppy comes up with another twisted syntax party 
trick, it makes software development even more inaccessible to 
handicapped people like myself.

I like Python for many reasons but a very important one is that it is 
something I can dictate using unenhanced speech recognition tools like 
NaturallySpeaking.  It lets me get my work done and the typing idea have 
to do, doesn't aggravate the pain in my hands/arms.

So anytime someone creates something with lots of special characters and 
StUDlYCapS, I want to scream but I don't because I don't want to damage 
my voice like I did my hands.

Every time there is something special in the text that deviates from 
English, I need to go build a special tool to translate English to that 
SpclEnv.  It is unfortunately not an easy process because most tools nor 
NaturallySpeaking are built for signaling context changes or making 
context changes.  The end result being that I try to create only simple 
grammars and avoid using tools that cause me physical pain.

having said that, I should probably admit to having created my own web 
page template tool.  It is a very simple tool based on the opagcgilib.py 
Toolkit.  since opagcgilib.py uses a dictionary as its input, I created 
a dictionary derivative that when an entry is read, it runs the value 
through opagcgilib.py.  when a substitution occurs, it triggers a 
recursive run through opagcgilib.py until a value has no substitutions.

The end effect is if you stuff a dictionary with a template and then all 
the components that will be requested during substitutions, you can 
merge these elements together into a single HTML page.  What's a very 
nice is that you can just change the elements you need for subsequent 
pages. there are some helper functions for importing pages or fragments 
thereof into the dictionary.

the user experience of editing these fragments is actually quite easy. 
All fragments are complete HTML pages and can be edited with an ordinary 
HTML editor.  The only thing that is special is that sometimes you see 
%%main_body%% in a fragment.  Everything else is just the same which is 
good because high-level editing of HTML is far easier if you are using 
speech recognition.  (Are you starting to get a sense of a theme here... :-)

here is a fragment from the camram web site construction code 
(unfortunately line wrapped)

zodiac = inflatable()
zodiac["top"] = extract_all("top_template.html")
zodiac["copyright_date"] = "2002-2004"
zodiac["main_welcome"], zodiac["title"] = 
extract_core("main_welcome.html", True)
zodiac["main_news"] = extract_core("main_news.html")
expel_all ( zodiac["top"], "output/index.html")


# set up for all internal pages
zodiac["top"] = extract_all("internal_template.html")

# now do only per page changes

# pages referred to by the top menus
zodiac["title"] = "c a m r a m: Download It:"
zodiac["body_text"], zodiac["title"]  = extract_core("download.html", True)
expel_all ( zodiac["top"], "output/download.html"

--------------

and yes, this is what Python code written by speech recognition looks like.

---eric





More information about the Python-list mailing list