TemplateWriter

A general class that can take a directory layout and apply template parameters to it Very unsophisticated but workable. For a more sophisticated take that walks through object trees, see TemplateEngine.

ignored_files: list

 

__init__(self, template_dir, replacements=None, file_filter=None, **opts): 

 

@property
replacements(self): 

 

apply_replacements(self, string): 

Applies the defined replacements to the

  • string: Any
  • :returns: _

 

write_file(self, template_file, out_dir, apply_template=True, template_dir=None): 

writes a single file to dir and fills the template from the parameters passed when intializing the class

  • template_file: str

    the file to load and write into

  • out_dir: str

    the directory to write the file into

  • apply_template: bool

    whether to apply the template parameters to the file content or not

  • :returns: _

 

iterate_write(self, out_dir, apply_template=True, src_dir=None, template_dir=None): 

Iterates through the files in the template_dir and writes them out to dir

  • :returns: _

Feedback

Examples

Templates

Documentation