I built a nice html templater!

D

Derick van Niekerk

Ok - so it's not really an awesome achievement and only handles basic
templating needs (no loops and other programming constructs) but maybe
someone will find it useful.

It replaces any xml block where the id attribute is specified with
contents provided - a description is provided in the comments.

http://pastebin.com/m76f57ae2

My knowledge of python is limited and I would like someone to help me
with wrapping a command line interface around this function. I need
switches to specify input file, output file, key/value pairs for
variable substitution and key/value pairs for substituting blocks with
file contents (there is some clarification in the comments)

Any help would be appreciated.

Of course - feel free to use the code as you wish when you wish if you
wish :)

-d-
 
T

Tim Roberts

Derick van Niekerk said:
Ok - so it's not really an awesome achievement and only handles basic
templating needs (no loops and other programming constructs) but maybe
someone will find it useful.

<sarcasm>
Sure, that's what the world needed. We didn't have enough Python HTML
templaters already.
</sarcasm>

Did you take even 3 minutes to look for a solution before you wrote this?
There is even a nearly identical solution in the Python cookbook.
 
S

Steve Holden

Tim said:
<sarcasm>
Sure, that's what the world needed. We didn't have enough Python HTML
templaters already.
</sarcasm>

Did you take even 3 minutes to look for a solution before you wrote this?
There is even a nearly identical solution in the Python cookbook.

While I agree it was a little naive to expect a huge amount of interest
I think there's educational value in building a templating system of
your own. Sarcasm id the lowest form of wit, and there's no real need
for it here. You'd have been better saving your ire for someone who
really deserves it. Sadly there are plenty around.

regards
Steve
 
E

Eric S. Johansson

Steve said:
While I agree it was a little naive to expect a huge amount of interest
I think there's educational value in building a templating system of
your own. Sarcasm id the lowest form of wit, and there's no real need
for it here. You'd have been better saving your ire for someone who
really deserves it. Sadly there are plenty around.

my replication of work was motivated by a very different need. I built a web
framework that is friendly to speech recognition users. It uses plain English
words and very little special punctuation. the internal CGI environment is also
very simple in case you have a memory deficit and need to refresh your memory on
the functionality between uses. Almost every HTML template system, and web
framework I've seen look like they are designed to exclude disabled users.
Special punctuation, special spacing rules, non-English character sequences,
complex APIs, and lots of APIs say to the world "no disabled need apply".

Before you protest and say that disabled users are a special case, remember that
almost everyone becomes disabled as a result of aging or accident. a simple
broken wrist or arm could keep you from doing your job. arthritis and other
joint disorders will make keyboards something you cannot stand the touch. you
will not escape needing some form of accessibility tools if you decide to keep
using computers.

Now you're faced with a choice. Do you want to design and build things that you
will not be able to use at some point or do you want to build systems that can
be used by you now, and you in the future. let me play from personal
experience, it's far easier to build accessible systems before you need them
than after.
 
C

Carl Banks

<sarcasm>
Sure, that's what the world needed.  We didn't have enough Python HTML
templaters already.
</sarcasm>

Did you take even 3 minutes to look for a solution before you wrote this?
There is even a nearly identical solution in the Python cookbook.

He probably wrote his own faster than it would have taken him to
search for existing systems, and as an added bonus wouldn't have had
to work around all those things that are almost but not quite the way
he wanted.

Cut him some slack.


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top