-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'api_redesign' into development
- Loading branch information
Showing
7 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use tera::Context; | ||
use terarium::{Template, TerariumBuilder}; | ||
|
||
|
||
/// When primary language is missing, the fallback language can be used. | ||
fn main() { | ||
let terarium = TerariumBuilder::default() | ||
.add_template( | ||
"my_template".to_owned(), | ||
Template::default().content_builder() | ||
.add_content("This is english template, because no czech template is available".to_owned(), vec!["en".to_owned()]) | ||
.build() | ||
) | ||
.build().unwrap(); | ||
|
||
// The EN template will be rendered | ||
let result = terarium.render_template(&Context::new(), "my_template", "cs", Some("en")).unwrap(); | ||
println!("{}", result); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use tera::Context; | ||
use terarium::{Template, TerariumBuilder}; | ||
|
||
/// The Terarium can render single template. | ||
fn main() { | ||
let terarium = TerariumBuilder::default() | ||
.add_template( | ||
"my_template".to_owned(), | ||
Template::default().content_builder() | ||
.add_content("This is my template #{{tpl_number}}".to_owned(), vec!["en".to_owned()]) | ||
.add_content("Toto je šablona #{{tpl_number}}".to_owned(), vec!["cs".to_owned()]) | ||
.build() | ||
) | ||
.build().unwrap(); | ||
|
||
let mut ctx = Context::new(); | ||
ctx.insert("tpl_number", "13"); | ||
|
||
let output_en = terarium.render_template(&ctx, "my_template", "en", None).unwrap(); | ||
let output_cs = terarium.render_template(&ctx, "my_template", "cs", None).unwrap(); | ||
|
||
println!("\nEnglish:\n"); | ||
println!("{}\n", output_en); | ||
|
||
println!("\nCzech:\n"); | ||
println!("{}\n", output_cs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters