just_template
a tool for code gen via templates
Template File Writing Rules
just_template gens repetitive code using three core concepts: impl_mark, impl_area, and param.
-
impl_mark Mark an "impl point" with a line starting with 10
>chars:>>>>>>>>>> NAME. Used for positioning. The system extracts the matchingimpl_areacontent and expands it here. -
impl_area Declare a reusable code template:
@@@ NAME >>>[template content]@@@ <<<Inside, use param placeholders like<<<PARAM>>>. When adding an impl via cmd (e.g.,insert_impl!), the system copies the area, replaces params, and appends to the impl_mark. -
param
- Params outside an impl_area are replaced globally.
- Params inside are replaced per-impl when generating.
Example:
Template:
// Auto generated
use HashMap;
pub async
Run cmds:
tmpl!;
The arms impl_area becomes:
"my" => Some,
"you" => Some,
Final expanded code:
// Auto generated
use HashMap;
pub async
Installation
Add this to your Cargo.toml:
[]
= "0.1"
License
This project is dual-licensed under MIT and Apache 2.0. See the LICENSE file for details.