guidon is a french word for handlebars.
guidon is a small library which aims to speed up project initialization with templates.
toml
[dependencies]
guidon = "0.2"
guidon performs templating based on handlebars templating system.
Files to be handles needs to have an .hbs
extension. Folders and files names can be templatized too : `{{folder/subfolder}}
The entry point is the Guidon structure.
```rust, no_run use guidon::Guidon; use std::collections::HashMap; use std::path::PathBuf;
let mut guidon = Guidon::new(PathBuf::from("path/to/template/dir"));
let mut vars = HashMap::new();
vars.insert("key1".tostring(), "value1".tostring());
guidon.apply_template("path/to/destination").unwrap();
``
With this initialization:
* guidon will use the vars map to find substitution values.
* guidon will parse the directory
path/to/template/dir/template
* the result will be written in
path/to/destination`
guidon implements a TryNew trait to initialize from a dir or a git repo
```rust, no_run use guidon::{Guidon, TryNew};
let mut guidon = Guidon::try_new("path/to/template/dir").unwrap();
``
With this initialization:
* guidon will init the substitution variables from
path/to/template/dir/variables.toml
* guidon will parse the directory
path/to/template/dir/template`
```rust, no_run use guidon::{Guidon, TryNew};
let mut guidon = Guidon::trynew("path/to/template/dir/myvars.toml").unwrap();
guidon.usetemplatedir(false);
``
With this initialization:
* guidon will init the substitution variables from
path/to/template/dir/my_vars.toml
* guidon will parse the directory
path/to/template/dir`
```rust, no_run use guidon::{{Guidon, TryNew, GitOptions}};
let git = GitOptions::builder()
.repo("url/to/repo")
.credentials(("user".tostring(), "password".tostring()))
.build()
.unwrap();
let mut guidon = Guidon::try_new(git);
``
With this initialization
* guidon will clone the repo to a temporary directory
* guidon will init the substitutions variables from
tmp/dir/template.toml
* when applying template, guidon will parse the directory
tmp/dir/template`
The configuration file is structured as follows : ```toml
[variables] test1 = "test 1" test2 = "test 2" ```
The git initialization is a feature that can be deactivated.
In Cargo.toml
toml
[dependencies.guidon]
version = "0.2"
default-features = false
guidon uses the log facade.
TODO
The minimum rust version is 1.38.0
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in guidon by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.