Skip to content

Commit

Permalink
Adds changes for updating template resources (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
desaikd authored Jun 10, 2024
1 parent 4959fdf commit 1262088
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/ion/commands/beta/generate/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ impl<'a> CodeGenerator<'a, RustLanguage> {
// This allows packaging binary without the need of template resources.
tera.add_raw_templates(vec![
("struct.templ", templates::rust::STRUCT),
("scalar.templ", templates::rust::SCALAR),
("sequence.templ", templates::rust::SEQUENCE),
("util_macros.templ", templates::rust::UTIL_MACROS),
("import.templ", templates::rust::IMPORT),
("nested_type.templ", templates::rust::NESTED_TYPE),
("result.templ", templates::rust::RESULT),
Expand Down Expand Up @@ -77,6 +80,9 @@ impl<'a> CodeGenerator<'a, JavaLanguage> {
// This allows packaging binary without the need of template resources.
tera.add_raw_templates(vec![
("class.templ", templates::java::CLASS),
("scalar.templ", templates::java::SCALAR),
("sequence.templ", templates::java::SEQUENCE),
("util_macros.templ", templates::java::UTIL_MACROS),
("nested_type.templ", templates::java::NESTED_TYPE),
])
.unwrap();
Expand Down
24 changes: 24 additions & 0 deletions src/bin/ion/commands/beta/generate/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ pub(crate) mod java {
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/java/class.templ"
));
pub(crate) const SCALAR: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/java/scalar.templ"
));
pub(crate) const SEQUENCE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/java/sequence.templ"
));
pub(crate) const UTIL_MACROS: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/java/util_macros.templ"
));
pub(crate) const NESTED_TYPE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/java/nested_type.templ"
Expand All @@ -20,6 +32,18 @@ pub(crate) mod rust {
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/rust/struct.templ"
));
pub(crate) const SCALAR: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/rust/scalar.templ"
));
pub(crate) const SEQUENCE: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/rust/sequence.templ"
));
pub(crate) const UTIL_MACROS: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/rust/util_macros.templ"
));
pub(crate) const RESULT: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/bin/ion/commands/beta/generate/templates/rust/result.templ"
Expand Down

0 comments on commit 1262088

Please sign in to comment.