diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-11-19 09:18:41 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-11-19 09:18:41 -0500 |
commit | 356f9f943a34c6d059fec8fcea43b377a977f55c (patch) | |
tree | 870135d27df464607ce3221b7f0d50b0fbe2ca35 | |
parent | 37c199b96ddf565a0e7726ad2981960d457b5ef1 (diff) | |
download | bcfg2-356f9f943a34c6d059fec8fcea43b377a977f55c.tar.gz bcfg2-356f9f943a34c6d059fec8fcea43b377a977f55c.tar.bz2 bcfg2-356f9f943a34c6d059fec8fcea43b377a977f55c.zip |
examples: Use new __default__ magic in TemplateHelper example
-rw-r--r-- | examples/TemplateHelper/include.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/TemplateHelper/include.py b/examples/TemplateHelper/include.py index be0034f52..fcdb42ac9 100644 --- a/examples/TemplateHelper/include.py +++ b/examples/TemplateHelper/include.py @@ -5,14 +5,13 @@ Synopsis: {% python import os - include = metadata.TemplateHelper['include'] - custom = include.IncludeHelper(metadata, path).files(os.path.basename(name)) + custom = IncludeHelper(metadata, path).files(os.path.basename(name)) %}\ {% for file in custom %}\ - ########## Start ${include.describe_specificity(file)} ########## + ########## Start ${describe_specificity(file)} ########## {% include ${file} %} - ########## End ${include.describe_specificity(file)} ########## + ########## End ${describe_specificity(file)} ########## {% end %}\ This would let you include files with the same base name; e.g. in a @@ -20,7 +19,7 @@ template for ''foo.conf'', the include files would be called ''foo.conf.G_<group>.genshi_include''. If a template needs to include different files in different places, you can do that like so: - inc = metadata.TemplateHelper['include'].IncludeHelper(metadata, path) + inc = IncludeHelper(metadata, path) custom_bar = inc.files("bar") custom_baz = inc.files("baz") @@ -33,7 +32,7 @@ from ''baz.conf.G_<group>.genshi_include''. import os import re -__export__ = ["IncludeHelper", "get_specificity", "describe_specificity"] +__default__ = ["IncludeHelper", "get_specificity", "describe_specificity"] class IncludeHelper(object): |