Activity Not Available
0
I Use This!

Project Summary

Analyzed 4 months ago. based on code collected 4 months ago.

The main functions and classes of the ctemplate library are wrapped as native Python objects. This enables quick prototyping and testing of a ctemplate system.

Run python internal help() for an API overview: $ python -c "import ctemplate; help(ctemplate)"

Example

# loads example.tpl in current directory
template = ctemplate.Template("example.tpl", ctemplate.DO_NOT_STRIP)
dictionary = ctemplate.Dictionary("my example dict")
dictionary.SetValue("VALUE1", "TEST1")
# dict setters call SetValue() automatically
dictionary["VALUE2"] = "TEST2"
# all objects except booleans are converted to strings with str()
dictionary["NUMBER"] = 87411 # stores "87411"
dictionary["TUPLE"] = (1, 2, 3) # stores "(1, 2, 3)"
# Sections
dictionary.ShowSection("A_SECTION")
# boolean True calls ShowSection() automatically
dictionary["IN_CA"] = True
# boolean False is ignored (ie. this statement has no effect)
dictionary["IGNORED"] = False
# And of course the expand function
print template.Expand(dictionary)

Share

In a Nutshell, python-ctemplate...

Activity

30 Day Summary

Apr 10 2016 — May 10 2016

12 Month Summary

May 10 2015 — May 10 2016

Community

Ratings

Be the first to rate this project
 
Click to add your rating
   Spinner f6ecff617ec2ba7f559e6f535cad9b70a3f91120737535dab4d4548a6c83576c
 
Review this Project!