Skip to content

feat(lib): introduce structured templates #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2025
Merged

Conversation

lalvarezt
Copy link
Owner

Structured Templates (Advanced)

NEW in v0.13.0: Apply multiple inputs to different template sections with individual separators.
This enables powerful scenarios like batch processing, command construction, and data transformation.

use string_pipeline::Template;

// Multiple inputs per template section with different separators
let template = Template::parse("Users: {upper} | Files: {lower}").unwrap();
let result = template.format_with_inputs(&[
    &["john doe", "jane smith"],  // Multiple users for first section
    &["FILE1.TXT", "FILE2.TXT"]   // Multiple files for second section
], &[" ", ","]).unwrap();         // Space separator for users, comma for files
assert_eq!(result, "Users: JOHN DOE JANE SMITH | Files: file1.txt,file2.txt");

// Template introspection
let sections = template.get_template_sections(); // Get template section info
assert_eq!(sections.len(), 2); // Two template sections: {strip_ansi|lower} and {}

Key Features:

  • 🎯 Flexible Input: Each template section can receive multiple input values
  • ⚙️ Custom Separators: Individual separator for each template section
  • 🔍 Introspection: Examine template structure before processing
  • 🏗️ Batch Processing: Perfect for processing multiple items per section

gives the option to pass different arguments to the different sections
inside a MultiTemplate
@lalvarezt lalvarezt self-assigned this Aug 18, 2025
@lalvarezt lalvarezt added the enhancement New feature or request label Aug 18, 2025
@lalvarezt
Copy link
Owner Author

@alexpasmantier care to have a look, this solves some of the issues related to multiple selection in television

@lalvarezt lalvarezt changed the title qfeat(lib): introduce structured templates feat(lib): introduce structured templates Aug 18, 2025
@lalvarezt lalvarezt force-pushed the structured-templates branch from 7446662 to 0e3cecf Compare August 18, 2025 20:18
@lalvarezt lalvarezt merged commit b140f58 into main Aug 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant