Expand description
§textcon
A template processing library and CLI tool for expanding file and directory references in text templates. Designed to prepare content for Large Language Models (LLMs) by embedding file contents and directory structures directly into templates.
§Features
- Process templates containing
{{ @file.txt }}references - Expand file contents inline
- Generate directory tree representations
- Security: prevents path traversal attacks
- Flexible configuration options
§Usage
§As a Library
use textcon::{process_template, TemplateConfig};
let template = "Here's my code:\n{{ @src/main.rs }}\n\nProject structure:\n{{ @. }}";
let config = TemplateConfig::default();
match textcon::process_template(template, &config) {
Ok(result) => println!("{}", result),
Err(e) => eprintln!("Error: {}", e),
}§As a CLI Tool
# Process a template file
textcon template.txt
# Process template from stdin
echo "Code: {{ @main.rs }}" | textcon
# Process with custom base directory
textcon template.txt -b /path/to/projectRe-exports§
pub use error::Result;pub use error::TextconError;pub use template::TemplateConfig;pub use template::TemplateReference;pub use template::find_references;pub use template::process_reference;pub use template::process_template;pub use template::process_template_file;